tags:

views:

195

answers:

6

I want to hide the guts of my URL programmatically.
I know I can use:

Server.Transfer("url",boolean)

This is not what I want in this case. I would like to be able to manipulate the URL after I get the variables I need.

How would I do this in ASP.NET?


Edit:

My URL:

URL.aspx?st=S&scannum=481854

I want to change it when the page loads to just be URL.aspx? but I need to first get the st and scannum values.

+1  A: 

If you're passing in variables that you don't want displayed in the URL, why not use POST instead of GET?

Amber
Ok.. how exactly can i do that?i'm using response.redirect to set my url with variables.
Eric
+1  A: 

You will have to provide more details on what your desired end result is. There are many options for manipulating the URL.

Using POST will allow you to transfer information between pages without littering your URL with extra values. Using encryption will not hide the extra parameters, but will make them unreadable. Using a URL Rewriter you can use regex to have the user enter one URL, but actually load another.

Jay S
ok. I edited it my question to be more clear
Eric
A: 

I have answered a question similar to this in the past. I say similar, because I am not sure what exactly you are looking for, but I feel the need to post a link to the other question to see if it will help:

http://stackoverflow.com/questions/22869/asp-net-building-your-own-routing-system

Dale Ragan
+5  A: 

Have you seen this article that covers Url Rewriting in ASP.NET?

I recommend checking out ASP.NET MVC as well. MVC stands for Model View Controller. This framework will use a "controller" to route the end user to "views" that display your data (your "model"). MVC does all the routing for you based on the URL.

Frinavale
You can use routing without MVC as well... if you are scared to get wet... http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx
BigBlondeViking
That's very true BigBlondViking :)That's why I posted the link to the article that covers URL Rewriting in ASP.NET first. I'm very excited about MVC though. It's an amazing framework that was long over due. The separation of the data (model) from the user interface (the view) lets you keep your code very organized and I am a big fan of clean code. It also lets you structure the URLs for your site, which not only makes it easier for your end user to use the site but also lets you change the location of your resources (models and views) because they aren't tightly linked to the url any more.
Frinavale
A: 

Look at ASP.NET Routing for new Apps. Have you tried HttpContext.RewritePath Method (String) Cross-Page Posting in ASP.NET Web Pages

moo
A: 

It's not possible to do what I want to do. I would want to change the appearance of my url in javascript without refreshing. If this was possible, hackers would rule the world.

Eric