asp.net-mvc – MVC 3应用程序中的自定义Http处理程序
我正在使用Http Handler来本地化我的应用程序中使用的
javascript文件:
见: Localize text in JavaScript files in ASP.NET 我想使用提供的处理程序,所以我做了以下事情: 1)在Global.asax中使用此代码忽略路由 – 我添加了routes.IgnoreRoute(“{resource} .js.axd / {* pathInfo}”); RegisterRoutes方法的代码行如下所示: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.js.axd/{*pathInfo}"); routes.MapRoute( "Default",// Route name "{controller}/{action}/{id}",// URL with parameters new { controller = "Home",action = "Index",id = UrlParameter.Optional } // Parameter defaults ); } 2)我添加了< add path =“*.js.axd”verb =“*”type =“CamelotShiftManagement.HttpHandlers.ScriptTranslator”/>在Views文件夹中找到我的web.confing文件,看起来像这样: <system.web> <httpHandlers> <add path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" /> <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> </httpHandlers> 但是当我尝试访问以下URL时,我收到了一个Page not found错误: http://camelotshiftmanagement.com/Scripts/Administration/OrganizationalStructure.js.axd 我在这做错了什么? 进展: 访问http://camelotshiftmanagement.com/Scripts/Administration/OrganizationalStructure.js.axd这次产生了一个不同的错误:404.17请求的内容似乎是脚本,静态文件处理程序不会提供. 其他错误信息 Server Error in Application "CAMELOTSHIFTMANAGEMENT.COM" Internet Information Services 7.5 Error Summary HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler. Detailed Error Information Module: "StaticFileModule" Notification: "ExecuteRequestHandler" Handler: "StaticFile" Error Code: "0x80070032" Requested URL: "http://camelotshiftmanagement.com:80/Scripts/Administration/OrganizationalStructure.js.axd" Physical Path: "C:CodeCamelotShiftManagementCamelotShiftManagementScriptsAdministrationOrganizationalStructure.js.axd" Logon Method: "Anonymous" Logon User: "Anonymous" Most likely causes: The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions,the request will map to a different handler. Things you can try: If you want to serve this content as a static file,add an explicit MIME map. 那我在这里超过我的联盟… 解决方法
好的…所以我确实修好了(我想).
有两个问题: <handlers> <add name="CustomScriptHandler" path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" /> </handlers> 还有一个可以使用IIS管理器(7)完成的GUI过程: 服务器没有触发正确的处理程序并且代码运行. 我唯一不确定的是,我仍然需要一个带有.js.axd扩展名和.js扩展名的文件,因为处理程序会查找要处理的Javascript文件,服务器会查找.js.axd文件启动自定义处理程序. 如果有人有其他见解,一定要做. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – 503 – 服务器不可用 – .Net 2.0和4.0冲突
- asp.net-core – 返回404页面,不重定向
- asp.net中的pagemethods
- asp.net-mvc-3 – ASP.NET MVC3项目并不总是发布所有的视图
- asp.net-mvc – ASP.NET MVC:如何从Html.ActionLink链接中
- asp.net – 如何为.Net网站,Windows服务等创建安装程序?
- asp.net-mvc – 我在哪里设置MVC.NET的AuthorizeServices中
- asp.net-mvc-3 – 如何验证HTML输入以防止XSS?
- 如何运行ASP.Net页面的客户端验证?
- asp.net-mvc-4 – 带有绝对路径的ASP.NET MVC Bundle