我可以在多个.net应用程序中添加页脚吗?

时间:2021-07-24 08:00:50

I would like to implement google analitycs on a website that's a mix of classic asp and various .net applications. All classic ASP pages share a footer.inc file, so that's a no brainer. However, the .net pages don't share anything, and sometimes don't even use master pages. Is there a way i could compile a DLL, drop it into the GAC and just reference it in web.config?

我想在一个混合了经典asp和各种.net应用程序的网站上实现google analitycs。所有经典的ASP页面共享一个footer.inc文件,所以这是一个没有脑子的人。但是,.net页面不共享任何内容,有时甚至不使用母版页。有没有办法我可以编译DLL,将其放入GAC并在web.config中引用它?

Thanks!

1 个解决方案

#1


6  

You can make an IHttpModule, in which you add a filter to the response stream.

您可以创建一个IHttpModule,在其中向响应流添加过滤器。

In that filter, you can look for the closing body tag, (for instance), and add whatever markup you need, there. Here is an article with details on the approach: HttpFilters.

在该过滤器中,您可以查找结束体标记(例如),并在那里添加您需要的任何标记。这篇文章详细介绍了该方法:HttpFilters。

When you have the module ready, you can put the module in GAC, and reference it in the web.config for each of your applications. If you need on every .NET application on the server, you could also put it in the machine-wide web.config file (to save you the trouble of editing all the web.configs). This file is found in C:\Windows\System\Microsoft.NET\Framework\<version>\CONFIG

准备好模块后,可以将模块放在GAC中,并在web.config中为每个应用程序引用它。如果您需要在服务器上的每个.NET应用程序上,您也可以将它放在机器范围的web.config文件中(为了省去编辑所有web.configs的麻烦)。此文件位于C:\ Windows \ System \ Microsoft.NET \ Framework \ <版本> \ CONFIG中

#1


6  

You can make an IHttpModule, in which you add a filter to the response stream.

您可以创建一个IHttpModule,在其中向响应流添加过滤器。

In that filter, you can look for the closing body tag, (for instance), and add whatever markup you need, there. Here is an article with details on the approach: HttpFilters.

在该过滤器中,您可以查找结束体标记(例如),并在那里添加您需要的任何标记。这篇文章详细介绍了该方法:HttpFilters。

When you have the module ready, you can put the module in GAC, and reference it in the web.config for each of your applications. If you need on every .NET application on the server, you could also put it in the machine-wide web.config file (to save you the trouble of editing all the web.configs). This file is found in C:\Windows\System\Microsoft.NET\Framework\<version>\CONFIG

准备好模块后,可以将模块放在GAC中,并在web.config中为每个应用程序引用它。如果您需要在服务器上的每个.NET应用程序上,您也可以将它放在机器范围的web.config文件中(为了省去编辑所有web.configs的麻烦)。此文件位于C:\ Windows \ System \ Microsoft.NET \ Framework \ <版本> \ CONFIG中