Solved

URL Masking

Posted on 2009-05-03
1
255 Views
Last Modified: 2012-05-06
I have page name TestUrl.aspx when I execute this page I should display some random words in url, but I should not display the page name like TestUrl.aspx,
it should not be like
http://localhost:1156/WebSite3/mine/TestUrl.aspx
Please help me
Aspx File(Design File)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestUrl.aspx.cs" Inherits="mine_TestUrl" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span style="font-size: 72pt">Url Masking</span></div>
    </form>
</body>
</html>
 
 
code file(cs file)
public partial class mine_TestUrl : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
}

Open in new window

0
Comment
Question by:mannevenu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
Cognize earned 500 total points
ID: 24293583
I think what you are refering to is commonly called URL rewriting. You need to check the request value in Application_BeginRequest in global.asax, which could be something like http://localhost/MyRenamedPage.aspx

You then use the Context.RewritePath( redirectString ); method to send the user to another resource as chosen by yourself - such as http://localhost:1156/WebSite3/mine/TestUrl.aspx

The Test.UrlRewriting.UrlRewriter.GetRedirectString( Request.Url.ToString(), Request.QueryString.ToString() ); method call in my code below is just a custom check for a predefined mapped URL.

Here you can see a good tutorial on url rewriting http://weblogs.asp.net/scottgu/


Fig.1
 
void Application_BeginRequest(object sender, EventArgs e)
    {
        //// Check if path is an alias for a real page. If so, rewrite path,
        //// else, allow user to continue to requested resource.
 
 
        
            string redirectString = Test.UrlRewriting.UrlRewriter.GetRedirectString( Request.Url.ToString(), Request.QueryString.ToString() );
 
            if ( redirectString != null )
            {
                Context.RewritePath( redirectString );
            }
 
    }

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question