Click here to Skip to main content
15,881,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have one page Default.aspx , i want to pass Query string with the url.
But i want URL should come in a appropriate format.

C#
protected void lnkForward_Click(object sender, EventArgs e)
   {
       try
       {
           string  UserName=Session["UserName"].ToString();
           string url = ~/Page2.aspx?UserName= + UserName;
           Response.Redirect(url, false);
       }
       catch (Exception)
       {

           throw;
       }
   }</pre>

Now it's coming as ' http://localhost:60160/TestFolder/Page2.aspx?UserName=Jay '.

I Want it should applear int the page2.aspx page as ' http://localhost:60160/TestFolder/Page2/Jay '
Posted
Updated 20-Mar-14 3:22am
v2

According to me, you can find this functionality in MVC application.
 
Share this answer
 
v2
Comments
mrityunjay3601 20-Mar-14 9:17am    
Can we use this in 3-tier architecture
Er. Ajay Chauhan 20-Mar-14 9:25am    
Clearly I don't know about it, once I tried hard to get this functionality in my N-tier Application through <rewriter>, it was ok on local host but got .aspx extension error while goes online.
mrityunjay3601 20-Mar-14 9:27am    
Okie Thanks Ajay .. Please let me know if u get any success .
mrityunjay3601 21-Mar-14 0:28am    
Okie
Thanks Ajay !!
XML
protected void lnkForward_Click(object sender, EventArgs e) 
{ 
try 
{
string  UserName=Session["UserName"].ToString();
string url = "~/Page2/" +UserName;
Response.Redirect(url, false);
 } 
catch (Exception) 
{   
throw; 
} 
}


in Web.config

<?xml version="1.0"?>
<!--
 For more information on how to configure your ASP.NET application, please visit
 http://go.microsoft.com/fwlink/?LinkId=169433
 -->
<configuration>
 <configSections>
 <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
 </configSections>
 <system.web>

 <urlMappings enabled="true">
 <add url="~/Static-Page" mappedUrl="~/Static.aspx" />
 </urlMappings>

 <httpModules>
 <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
 </httpModules>
 <compilation debug="true" targetFramework="4.0"/>
 </system.web>
 <rewriter>
 <rewrite url="~/Page/(.+)" to="~/Page2.aspx?User=$1"/>

 </rewriter>
</configuration>


 Add to DDL to the BIN

 Intelligencia.UrlRewriter.dll
 
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