views:

22

answers:

2

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

A: 

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.

eglasius
I already have .aspx pages ignored. Going LoginPage.aspx works fine, what doesn't work properly is the site root: http://dev01/SampleWebApp/ I tried ignoring "/" but asp.net gives me this error: The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character.
Darren
that's all I got ... actually, to override authorization you can apply it specifically to the login page, similar to http://stackoverflow.com/questions/3026293/how-to-test-asp-net-location-folder-authorization-programmaticly
eglasius
A: 

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.

Darren