I have a small .NET web app in an aspx file that currently has a form on the page. It takes the information from that form and does some stuff to it using a method in a <script> tag in the same file. Now I need a way to create a url, let's call it base_url.com/do_something/field1/field2/field3, where field1, field2, and field3 are the fields currently in the form, so that I can bypass the form all together and just run the app from a url. I am using IIS 7.0, this is not a project created in VS. Can anyone shed some light on how to do this?
            Asked
            
        
        
            Active
            
        
            Viewed 121 times
        
    2
            
            
        
        Mike Perrenoud
        
- 66,820
 - 29
 - 157
 - 232
 
        azrosen92
        
- 8,357
 - 4
 - 26
 - 45
 
2 Answers
0
            
            
        Well, assuming you're issuing a POST to an ASPX page, that sure is going to redirect, the code might look something like this:
var path = string.Format("base_url.com/do_something/{0}/{2}/{3}",
    Request.Form["field1"], Request.Form["field2"], Request.Form["field3"]);
then after getting the right path, simply do this:
Response.Redirect(path);
        Mike Perrenoud
        
- 66,820
 - 29
 - 157
 - 232
 
- 
                    But is the question asking how to make sure that gets to the right server method? I thought this question was about URL Rewriting on the server. – Bill Gregg Jun 13 '13 at 17:18
 - 
                    this is helpful, but I also need to know what @wagregg is suggesting... I'm pretty new to .NET – azrosen92 Jun 13 '13 at 17:19
 
0
            
            
        In ASP.Net MVC, you get URL Routing baked in. If this is an MVC application, then you can declare your mapping in your Global.asax file. See this answer: ASP.NET MVC Routes: How to define custom route
If you do not have an ASP.Net MVC application, then URL rewriting can be done directly in IIS. http://www.iis.net/downloads/microsoft/url-rewrite
HTH
        Community
        
- 1
 - 1
 
        Bill Gregg
        
- 7,067
 - 2
 - 22
 - 39
 
- 
                    From what I've been reading about URL rewriting, it seems like all it does is converts a URL with a query string into a clean URL, but I still need to map the clean URL to some sort of action. Can this be done with a URL rewrite? – azrosen92 Jun 13 '13 at 17:57
 - 
                    You can do anything you'd like. You want to map a Clean Url to a url with a query string. It works like that too. People do that for SEO all the time. – Bill Gregg Jun 13 '13 at 17:59