开发者

Home page in MVC app is not correctly routed with IIS 7.5

I deployed an MVC app in Windows Server 2008 R2 with IIS 7.5 (Integrated Mode). The first page that the browser should show if I enter the address (http://192.168.3.5:2011/) is a Login page. The thing is that instead I found that it executes the first ActionResult returner method found in the controller that is in the top of a allegued alphabetically ordered list ???. On the other hand if I type http://192.168.3.5:2011/Default.aspx everything goes correct; it shows the Login page. My routing table in the Global.asax is defined as:

   public class MvcApplication : System.Web.HttpApplication
   {
       public static void RegisterRoutes(RouteCollection routes)
       {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

          routes.MapRoute(
            "Default", 
            "{controller}/{action}/{id}", 
             new { controller = "Login", action = "Login", id = "" } 
          );
       }

       protected void Application_Start()
       {
           RegisterRoutes(RouteTable.Routes);
       }
   }

The outcome that I get is that it redirects to the following address: http://192.168.3.5:2011/Account/LogOn?ReturnUrl=%2f and then configuration error is thrown:

<providers>
         <clear />
         <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" />
</providers>

There is a LogOn method, which is the first one declared in the Account Controller, which is the first controller alphabeticaly ordered.

In IIS 6.0 classic mode works fine but not in IIS 7.5 (Integrated mode). This is driving me crazy.

Thank you for your help.

开发者_C百科

Regards.


It would appear to me that authentication is configured in the one case and not in the other. The Account/Logon has the return URL parameter which is typically provided due to a redirect when the original request isn't authenticated.


You can try defining id as a UrlParameter.Optional:

routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Login", action = "Login", id = UrlParameter.Optional } // Parameter defaults
            );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜