Click here to Skip to main content
15,887,979 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Step.1 create Default page.And add a control like a link button.
HTML
<asp:LinkButton ID="Linkbtn" runat="server" PostBackUrl="~/saleem">Redirect</asp:LinkButton>

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.
XML
<system.web>
    <httpModules>
      <add name="picurls" type="picurls"/>
    </httpModules>
</system.web>

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.
C#
>>use these name spaces
using System.Web.Configuration;
using System.Web.Handlers;

Step.6 Inherit IHttpModule like this.
C#
  public class picurls :IHttpModule
  {
      public picurls()
      {
//
// TODO: Add constructor logic here
//
      }

      #region
      public void Dispose()
      {
      }

Step.7 Write a method in this class
C#
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");
    }
}

Step 8 Write a Init method
C#
public void Init(HttpApplication contaxt)
{
    contaxt.BeginRequest += new EventHandler(hideUrl);
}

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.
Posted
Updated 12-Sep-13 21:35pm
v3
Comments
Thanks7872 13-Sep-13 3:37am    
If i do all these,how would you come to know what the problem is?
Instead of giving us the steps, why don't you explain what is the requirement and what have you done in order to achieve that?

1 solution

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?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900