为什么的MapPageRoute / RedirectToRoute合作开发计算机上,但不是生产服务器上? [英] Why is MapPageRoute / RedirectToRoute working on dev machine but not on production server?

查看:100
本文介绍了为什么的MapPageRoute / RedirectToRoute合作开发计算机上,但不是生产服务器上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个普通web表单项目(非MVC),我成功地实施了的MapPageRoute和RedirectToRoute场景。页面路由由数据库查找,因为我翻译的查询字符串进行(例如?过滤= 112 /我友好的URL)。它可以很好地运行VWD 2010防爆preSS我的开发机和包括ASP.NET开发服务器上。 ASP.NET版本为4.0.30319.272。然而,当我运行在生产(IIS7)框中的项目,我坐上页映射找不到网页错误。该网站的其余部分/页运行正常。我的直觉是,页面处理是问题的根源,但我不明白它是什么,或者为什么。它可能与IIS7如何处理目录与文件名,并可以从我的程序路由物理的.aspx到目录式的名称出现的干扰做。我的IIS7和放大器; web.config中的知识是有点弱在这个领域。

I have a regular webforms project (non-MVC) and I successfully implemented a MapPageRoute and RedirectToRoute scenario. The page routing is done by database lookups because I am translating query strings (e.g. ?filter=112 to /my-friendly-url). It works nicely on my development machine running VWD 2010 Express and the included ASP.NET Development Server. The ASP.NET version is 4.0.30319.272. However, when I run the project on the production (iis7) box, I get page not found errors on the mapped pages. The rest of the site/pages run fine. My gut feeling is that the page handling is the root of the issue, but I can't figure what it is or why. It may have to do with how iis7 handles a directory vs. a filename and the interference that may arise from my program routing physical .aspx to directory-style names. My iis7 & web.config knowledge is a bit weak in this area.

下面我的Global.asax的摘录:

Here an excerpt of my global.asax:

   void Application_Start(object sender, EventArgs e)
   {
      // Code that runs on application startup
      RegisterRoutes(RouteTable.Routes);
   }

   public static void RegisterRoutes(RouteCollection routes)
   {
      routes.Clear();
      routes.RouteExistingFiles = false;
      routes.Ignore("{resource}.axd/{*pathInfo}"); //ignore axd files, prevents javascript/routing collisions
      routes.MapPageRoute("Education", "{category}/{section}", "~/product/education/default.aspx");
      routes.MapPageRoute("EducationLanding", "{category}", "~/product/education/default.aspx");
   }

Web.config文件:的处理程序部分。

Web.config: Handlers section of

 <handlers>
     <remove name="StaticFile" />
     <remove name="PageHandlerFactory-Integrated-4.0" />
     <add verb="*" path="ajax/*.ashx" name="Ajax" type="Ajax.PageHandlerFactory, Ajax" />
     <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
     <add name="PageHandlerFactory-Integrated-4.0" path="*.aspx" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
     <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />  
  </handlers>

在此先感谢,
约翰·

Thanks in advance, John

推荐答案

展望页面处理导致我在web.config中的模块部分,我发现我的答案在这里SO(<一个href=\"http://stackoverflow.com/questions/5393290/iis-7-ignores-mappageroute-without-file-extentions\">IIS 7忽略不的MapPageRoute文件扩展)。为什么我没有在我所有的previous搜索我不知道找到。看哪:

Looking into page handling led me to the modules section of the web.config and I found my answer here on SO (IIS 7 ignores MapPageRoute without file extentions). Why I didn't find this in all my previous searches I shall not know. Behold:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

感谢您@Christoph

Thank you @Christoph

这篇关于为什么的MapPageRoute / RedirectToRoute合作开发计算机上,但不是生产服务器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆