Solved

URL Masking

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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