Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Can any one help me how to proceed to write the code for the URL encryption?
Posted
Updated 28-Apr-11 23:51pm
v2

Not sure why do you want to do that? Usually, urls should be readable enough.
 
Share this answer
 
Comments
Ankur\m/ 29-Apr-11 5:54am    
I guess he meant rewriting the URL.
rakesh4657 29-Apr-11 6:18am    
I M Workin On The Project So I need it.
Ankur\m/ 29-Apr-11 6:23am    
[comment from OP]
I M Workin On The Project So I need it.
Start here - URL rewriting in asp.net[^]
 
Share this answer
 
Comments
rakesh4657 29-Apr-11 6:24am    
[4:09:51 PM] GK: void Application_BeginRequest(object sender, EventArgs e)
{
/*( string curruntpath = Request.Path.ToLower();


curruntpath = curruntpath.Trim();
bool isredirected = curruntpath.EndsWith(".aspx");
bool isredirected2 = curruntpath.EndsWith(".html");
bool isredirected3 = curruntpath.EndsWith(".jpg");
bool isredirected4 = curruntpath.EndsWith(".jpeg");
bool isredirected5 = curruntpath.EndsWith(".gif");
bool isredirected6 = curruntpath.EndsWith(".png");
// string atr = curruntpath.Substring(curruntpath.IndexOf("/"));
if (!isredirected && !isredirected2 && !isredirected3 && !isredirected4 && !isredirected5 && !isredirected6)
{


HttpContext obj = HttpContext.Current;
string finalurl = curruntpath + ".aspx";


if (System.IO.File.Exists(Server.MapPath(finalurl)))
{
obj.RewritePath(finalurl);
}
else
{
obj.RewritePath("Error.aspx");
}
}

if (curruntpath.EndsWith(".aspx"))
{

HttpContext obj = HttpContext.Current;
//obj.RewritePath("Tohideextentions.aspx");
}*/

}

Will The Above Code Work.
I m Not Gettin Can U Help me.
Ankur\m/ 29-Apr-11 6:43am    
Man I wrote a big comment explaining things, but it somehow disappeared. I can't write that again. :doh: Brief - The code seems fine to me except the MapPath part. Check if that gives you a correct part. And remove the comments from the whole program and from line //obj.RewritePath("Tohideextentions.aspx"); You will have to write code to hide aspx part without which the rewriting makes no sense.
[4:09:51 PM] GK: void Application_BeginRequest(object sender, EventArgs e)
{
/*( string curruntpath = Request.Path.ToLower();

curruntpath = curruntpath.Trim();
bool isredirected = curruntpath.EndsWith(".aspx");
bool isredirected2 = curruntpath.EndsWith(".html");
bool isredirected3 = curruntpath.EndsWith(".jpg");
bool isredirected4 = curruntpath.EndsWith(".jpeg");
bool isredirected5 = curruntpath.EndsWith(".gif");
bool isredirected6 = curruntpath.EndsWith(".png");
// string atr = curruntpath.Substring(curruntpath.IndexOf("/"));
if (!isredirected && !isredirected2 && !isredirected3 && !isredirected4 && !isredirected5 && !isredirected6)
{

HttpContext obj = HttpContext.Current;
string finalurl = curruntpath + ".aspx";

if (System.IO.File.Exists(Server.MapPath(finalurl)))
{
obj.RewritePath(finalurl);
}
else
{
obj.RewritePath("Error.aspx");
}
}
if (curruntpath.EndsWith(".aspx"))
{
HttpContext obj = HttpContext.Current;
//obj.RewritePath("Tohideextentions.aspx");
}*/
}


Can Any One Help Me Weather The Above Mentioned Code Is Right For The Entire URL In The Address Bar To Be Encoded/Encrypted.
 
Share this answer
 
Hi Rakesh..,

Where do trying to encrypt your URL. normally URL(Query strings) are supports Base64 encoding. if your Url contains a Special characters(spce,$,@,!,+ etc). client(browser) will encode the url and sends to server.

below links may helps you

Base64[^]

http://www.codeproject.com/KB/cs/base64encdec.aspx[^]
 
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