Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to redirect from MVC application to ASP.Net Web-form application with in same solution.

I have tried some method like this
C#
[HttpPost]
        public ActionResult Home(LoginUser lu)
        {
            return Redirect("http://localhost:51410/SessionWebFrom/Login.aspx");
        }



But got exception: 404 Error

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /SessionWebFrom/Login.aspx
Posted
Comments
Kornfeld Eliyahu Peter 5-Aug-15 3:20am    
It only means that there is no such page (application) at the given address...
The form of 'localhost:51410' hints to me that you are using the development server, the question is: there is a running application of Web Forms at that port?
F-ES Sitecore 5-Aug-15 4:50am    
As already mentioned, if you start your project from Visual Studio it will only start one web project by default. If you want it to start two you need to go into the config and say that both projects are to start. As a side note, hard-coding the domain\port into the code is also a bad idea as you will need to re-compile for each environment. You should put the target domain in a config setting and build the url from that so you can change it as needed.
Sunil Revankar 5-Aug-15 5:06am    
I tried as you said, but both the projects runs on individual tab.
My requirment is, I login into one application where there is a link in one view in that application, by click on that i need to open another app with the same credentials which i am storing in session.

I tried in the other way where i used session state management with sqlserver mode, there i am able to store the session details in the ASPState DB, but couldn't retrieve the session value in the other application.
F-ES Sitecore 5-Aug-15 5:12am    
Web apps maintain their own state, the fact that two apps are in the same solution is irrelevant, the live in isolation of each other. If you want to share credentials etc then you need to implement single sign on. Google "asp.net single sign on", but it is not a trivial or easy thing to do.
Sunil Revankar 5-Aug-15 4:50am    
So what could be the solution. Mr. Kornfeld

1 solution

You can redirect to anywhere from MVC action and you have to use RedirectResult for that. RedirectResult is a type of ActionResult.


For ex.


C#
public RedirectResult RedirectToAspx()
{
  return Redirect("/pages/index.aspx");
}

Hope it helps :)

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900