简体   繁体   English

我可以将URL重写http模块放在一个文件夹中吗?

[英]Can i put URL rewriting http module in a folder?

I am trying to make a generic URL rewrite methods, and i want it portable so i checked this article: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx which is very nice. 我正在尝试制作一个通用的URL重写方法,我希望它可移植,所以我查了这篇文章: http//weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting- with-asp-net.aspx这是非常好的。

But i want to put all my classes, http modules in one folder, then i can just paste this folder in any asp.net website and edit the web.config to point to this http module, thats it, without the need to add anything in the APP_Code as this article teaching. 但是我想把我所有的类,http模块放在一个文件夹中,然后我可以在任何asp.net网站上粘贴这个文件夹并编辑web.config来指向这个http模块,就是这样,而不需要添加任何东西在APP_Code中作为本文的教学内容。

My question is is that possible? 我的问题是可能吗? any conc or better ideas? 任何一个或更好的想法?

您始终可以将该代码编译为程序集(.dll),将其放在/ bin文件夹中并更新web.config文件。

The ASP.NET runtime only looks by default in a limited number of folders for code files that it compiles on the fly -- App_Code (and its subfolders) is one of them. ASP.NET运行时默认情况下在有限数量的文件夹中查找它即时编译的代码文件 - App_Code(及其子文件夹)就是其中之一。 If you place code in an arbitrary folder, it won't be found. 如果将代码放在任意文件夹中,则无法找到它。

The usual approach for what you describe is to build a DLL, and then drop it into the web site's bin folder. 您描述的常用方法是构建DLL,然后将其放入网站的bin文件夹中。 You would then have a separate project in Visual Studio for building the DLL. 然后,您将在Visual Studio中有一个单独的项目来构建DLL。 Using a subfolder in App_Code is another possibility. 在App_Code中使用子文件夹是另一种可能性。

You could also put your DLL into the GAC, which would make it accessible to all sites on a server. 您还可以将您的DLL放入GAC,这将使服务器上的所有站点都可以访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM