检查global.asax中的页面扩展 [英] check page extension in global.asax
本文介绍了检查global.asax中的页面扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在global.asax中的项目中检查.txt或.xml之类的页面扩展名. .asax页面.如果它在IIS或全局事件中具有某些设置,那么我该怎么做?
此致
RAJNI PAL
i want to check the page extension like .txt or .xml in my project in global.asax.if it ''s so , then redirect to another .aspx page.I don''t know where to check this page extension in global.asax page.if it''s having some setting in IIS or global events,then how do i do it?
Regards,
RAJNI PAL
推荐答案
您需要按以下方式处理Global.asax
文件的Application_BeginRequest
事件.
You need to handleApplication_BeginRequest
event ofGlobal.asax
file as following.
protected void Application_BeginRequest(object sender, EventArgs e)
{
string url = HttpContext.Current.Request.Url.AbsolutePath;
string extension = System.IO.Path.GetExtension(url);
switch (extension.ToLower())
{
case ".xml":
//Do Somtething.
break;
}
}
这篇关于检查global.asax中的页面扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文