问题描述
Step.1创建默认页面。添加一个像链接按钮的控件。
Step.1 create Default page.And add a control like a link button.
<asp:LinkButton ID="Linkbtn" runat="server" PostBackUrl="~/saleem">Redirect</asp:LinkButton>
您可以更改要替换页面的回发网址名称或扩展名。
步骤2打开Web配置文件并写入这在system.web标签中。
You can change postback url which you want to replace page name or extension.
Step.2 Open web config file and write this in system.web tag.
<system.web>
<httpModules>
<add name="picurls" type="picurls"/>
</httpModules>
</system.web>
步骤3添加新网页你想重定向。
页面名称如hide.aspx
步骤4在解决方案资源管理器中添加一个类文件>> App_Code名称如picurls.cs
在picurls.cs页面的第5步。
Step.3 Add new web page where you want redirect.
page name like hide.aspx
Step.4 Add a class file in solution explorer >>App_Code name as picurls.cs
Step.5 in picurls.cs page.
>>use these name spaces
using System.Web.Configuration;
using System.Web.Handlers;
Step.6像这样继承IHttpModule。 />
Step.6 Inherit IHttpModule like this.
public class picurls :IHttpModule
{
public picurls()
{
//
// TODO: Add constructor logic here
//
}
#region
public void Dispose()
{
}
Step.7在此课程中编写方法
Step.7 Write a method in this class
public void hideUrl(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
//here is name which you want to replace asp page name.
if (app.Request.RawUrl.ToLower().Contains("/saleem"))
{
//here page name where you want redirect.
app.Context.RewritePath( "~/hide.aspx");
}
}
步骤8编写Init方法
Step 8 Write a Init method
public void Init(HttpApplication contaxt)
{
contaxt.BeginRequest += new EventHandler(hideUrl);
}
现在运行Default.aspx页面并点击链接按钮。
然后你发现你的网址名字是chaingeurl / saleem
当我点击链接按钮我收到这样的服务器错误
Now run your Default.aspx page and click link button.
then you found that your url name is chaingeurl/saleem
when I click link button i get a server error like this
The HTTP verb POST used to access path '/WebSite23/Default' is not allowed.
推荐答案
这篇关于如何隐藏Asp.net扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!