Solved

URL Masking

Posted on 2009-05-03
1
249 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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