Custom Http Handler in MVC 3 Application

若如初见. 提交于 2019-12-05 16:21:58

Okay... so I did fix it (I think).

There were two problems: 1. the file name had a .js extention and not .js.axd as the handler needs. 2. I needed to register the handler to the IIS since it is a custom extension that is not recoginzed by default. To do that I added the following code under <system.webServer> node at the Main Web.Config file of my MVC application:

<handlers>
        <add name="CustomScriptHandler" path="*.js.axd" verb="*" type="CamelotShiftManagement.HttpHandlers.ScriptTranslator" />
</handlers>

There is also a GUI process that can be done using the IIS Manager (7): Open website node --> Handler Mapping --> Add Script Map

No the correct handler is fired by the server and the code runs.

The only thing I am not sure of is that i still have to have a file with an .js.axd extention and a .js extension becuse the handler looks for the Javascript file to process and the server looks for a .js.axd file to start the custom handler.

If anyone have other insights, by all means do.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!