C# 仅编译/预编译global.asax
是否有办法将global.asax文件编译或预编译到dll中,并在bin文件夹中使用它 我在这个文件中有一个许可证逻辑,其他文件不会由我编译 我还可以检查dll本身是否存在于bin文件夹中C# 仅编译/预编译global.asax,c#,asp.net,compilation,global-asax,precompile,C#,Asp.net,Compilation,Global Asax,Precompile,是否有办法将global.asax文件编译或预编译到dll中,并在bin文件夹中使用它 我在这个文件中有一个许可证逻辑,其他文件不会由我编译 我还可以检查dll本身是否存在于bin文件夹中 void Application_BeginRequest(object sender, EventArgs e) { //Application is allowed to run only on specific domains string[] safeDomains
void Application_BeginRequest(object sender, EventArgs e)
{
//Application is allowed to run only on specific domains
string[] safeDomains = new string[] { "localhost" };
if(!((IList)safeDomains).Contains(Request.ServerVariables["SERVER_NAME"]))
{
Response.Write("Thisweb application is licensed to run only on: "
+ String.Join(", ", safeDomains));
Response.End();
}
}
通过在Application指令中指定Inherits属性,可以将代码与global.asax文件分开。现在,您不必在Global.asax文件中编写代码
<%@ Application Inherits="Company.LicensedApplication" %>
现在,您可以在bin文件夹中安装带有已编译应用程序类的web应用程序。这比将许可证代码编译到程序集并从global.asax(和/或web.config)引用该程序集更好吗?我想那里也有一些实用工具,所以他们不能直接删除它而不使用它。人们可以反编译它,但这类人非常有限:)@HasanGürsoy你有时间尝试我建议的方法吗?我们如何从任何页面触发此文件的编译
void Application_BeginRequest(object sender, EventArgs e)
{
//Application is allowed to run only on specific domains
string[] safeDomains = new string[] { "localhost" };
if(!((IList)safeDomains).Contains(Request.ServerVariables["SERVER_NAME"]))
{
Response.Write("Thisweb application is licensed to run only on: "
+ String.Join(", ", safeDomains));
Response.End();
}
}