How do I get the site root to return the correct page w/ ASP.NET MVC + WebForms + ISS 6 Wildcard mapping?

StackOverflow https://stackoverflow.com/questions/3782972

  •  04-10-2019
  •  | 
  •  

Question

Currently, I'm converting a web application from web forms to ASP.NET MVC. The project has been converted and IIS 6 is setup w/ wildcard mapping. I also have made one MVC view/controller that works just fine. There is one problem though. When accessing the the site root, the routing engine kicks in and redirects the user to the default controller, instead of the default page setup in IIS. Is there a way to have IIS use the default page, before the routing engine kicks in?

If not...

I have tried to have the default controller just redirect the user to the default page (LoginPage.aspx). That works except that web.config authorization seems to think that the path is not authorized, thus it redirects to path that looks like http://dev01/SampleWebApp/LoginPage.aspx?ReturnUrl=%2fSampleWebApp

If go to the default controller directly (http://dev01/SampleWebApp/default/) the user gets re-directed to the login page with the correct path.

So is there a way to get the site root to by pass web.config authorization and redirect to the login page w/o the ReturnUrl?

Any help is greatly appreciated.

Thanks, Darren

Was it helpful?

Solution 2

So the solution my problem was to use url mappings in the web.config under the system.web tag:

<urlMappings enabled="true">
    <add url="~/" mappedUrl="~/LoginPage.aspx"/>
    <add url="~" mappedUrl="~/LoginPage.aspx"/>
</urlMappings>

"~/" will re-direct the http://dev01/SampleWebApp/ path.

"~" will re-direct the http://dev01/SampleWebApp path.

OTHER TIPS

at the top of the routes config in global.asax:

routes.IgnoreRoute("LoginPage.aspx");

or:

routes.IgnoreRoute("/");

haven't tried it, but one of those 2 options should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top