New file type for JavaScript content on IIS 7.5 integrated mode in order to render it
I want to create a new file type (for example .jsrender). Inside this file, there is some JavaScript cod开发者_Python百科e, but also some code nuggets like <%= txt1.ClientID %>
that have to be rendered before it's outputted.
How can I achieve this functionality? Also, how can I reference it? Can I do the following?
<script type="text/javascript" src="scripts/myjs.jsrender" runat="server" />
Will it work?
Also, I am going to reference it from code-behind file like below:
ScriptManager.RegisterStartupScript(
this.Page,
typeof(Page),
"JQueryUITimepickerAddonAjaxminJs",
String.Format("<script src='{0}' type='text/javascript' defer='defer'></script>",
ResolveUrl("~/Scripts/timepicker_addon/jquery-ui-timepicker-addon.ajaxmin.jsrender")),
false);
Do you think it will be rendered before it's outputted?
I know that we can create HttpModules for IIS, but I don't know what to do for this kind of functinality.
Thanks!
You just need to map that file extension to the ASP.Net handler. See the post below for doing that. Also look at his recommendation to use a rewrite to to just change the file extension dynamically.
How do I process .asp extensions using the .Net handler?
精彩评论