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
  •  | 
  •  

문제

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

도움이 되었습니까?

해결책 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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top