开发者

ASP .NET code in SVG?

开发者 https://www.devze.com 2023-03-08 06:50 出处:网络
I am looking for a way that I can add .SVG files to server-side code handlers or something, so that I can have server-side code handled in my .开发者_JAVA百科SVG files, without needing to change to th

I am looking for a way that I can add .SVG files to server-side code handlers or something, so that I can have server-side code handled in my .开发者_JAVA百科SVG files, without needing to change to the .ASPX file extension.

I know how to do this in PHP, just not in ASP .NET.


Implement an ASP.NET HTTP handler. See HTTP Handlers and HTTP Modules Overview.

Basically, you create an implementation of the System.Web.IHttpHandler interface and register it in web.config (you can register it for any URL pattern you like, so you can serve *.svg URLs and have the handler execute your logic).

If you're running an older IIS version, you will also need to add a file extension mapping to IIS configuration. For IIS 7, all you need to do to add the mapping is to register your handler in web.config.

0

精彩评论

暂无评论...
验证码 换一张
取 消