C# 在Webforms中合并MVC会降低性能,并在生产环境中重定向到登录页面
由于一个未定义的原因,当我尝试在webforms应用程序中集成MVC5时,在我的计算机上的global.asax中添加路由忽略后,它工作正常,但在生产环境中,会话似乎为空,因为它在从default.aspx获得302后重定向到login.aspx 显而易见的问题: 反应慢。~11.84 会议的问题C# 在Webforms中合并MVC会降低性能,并在生产环境中重定向到登录页面,c#,asp.net,asp.net-mvc,iis,webforms,C#,Asp.net,Asp.net Mvc,Iis,Webforms,由于一个未定义的原因,当我尝试在webforms应用程序中集成MVC5时,在我的计算机上的global.asax中添加路由忽略后,它工作正常,但在生产环境中,会话似乎为空,因为它在从default.aspx获得302后重定向到login.aspx 显而易见的问题: 反应慢。~11.84 会议的问题 public static void RegisterRoutes(RouteCollection routes) { //ignore aspx pages (web forms
public static void RegisterRoutes(RouteCollection routes)
{
//ignore aspx pages (web forms take care of these)
//routes.Add(new Route("favicon.ico", new StopRoutingHandler()));
routes.MapPageRoute("default", "", "~/default.aspx");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{folder}/{*pathInfo}", new { folder = "Services" });
//routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.MapRoute(
// Route name
"home",
// URL with parameters
"{controller}/{action}/{id}",
// Parameter defaults
new { controller = "home", action = "index", id = "" }
);
}
Web.config:
<system.webServer>
<staticContent>
<remove fileExtension=".woff"/>
<remove fileExtension=".svg"/>
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff"/>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml"/>
</staticContent>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</modules>
问题可能出在web.config文件中,请检查生产环境中是否包含以下内容
<configuration>
...
<system.webServer>
...
<modules>
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
...
</modules>
</system.webServer>
</configuration>
回复晚了,但我还是要发出去。设置:
runAllManagedModulesForAllRequests="true"
可能会对性能产生很大影响,例如图像加载的时间。在浏览器中,您可以分析网络活动,比较图像和脚本加载时间,并将此设置设置为true和false。相同的结果@peer,重定向到default.aspx,然后再重定向到login.aspx.monitoring by chrome developer tool