如何隐藏Asp.net扩展 [英] How to Hide Asp.net Extension

查看:62
本文介绍了如何隐藏Asp.net扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

推荐答案

这对我很好用



的错误不允许使用用于访问路径的HTTP动词POST'/ WebSite23 / Default'。



我有它,这是[包含]功能带来的不便





好​​提示



但是我有另一个问题我不知道如果这个方法能否实现?



在这种情况下我们发送一个文件夹链接httpsodule处理它并将其重定向到特定文件中,我们可以通过IF条件对其进行管理,以防我们在此文件夹下安装了多个文件。 br />




如果我发送到某个页面的完整链接,我想隐藏它,我只想要网站的名称无论打开哪个页面都可以显示!!!是否有可能使用这种方法?
This is working fine with me

for the error "The HTTP verb POST used to access path '/WebSite23/Default' is not allowed."

I had it and it's for the inconvenience in [contain] function


Good Tip

But I have another question I don't know If this method can fulfill or not?

in this case we send a folder link and httpmodule handle it and redirect it into the specific file and we can manage it through the IF condition in case we have more than file installed under this folder.


In case I am sending a full link to a certain page and I want to hide it and I want only the name of site only be shown regardless which page opened!!!? is it possible using this method?


这篇关于如何隐藏Asp.net扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆