1

I am in a trouble working with URL Rewrite 2.0 (in IIS7) for Web form web-app. In application there are job postings whose URL was not earlier SEO friendly and not in readable form as

*"http:www.mySite.com/candidate/JobDetails.aspx?ref=h_hj&JobPostingID=10049"*

I wrote Inbound Rule for that page i.e. for JobDetails.aspx as

Pattern to match: ^candidate/JobDetails\.aspx$

Conditions : {QUERY_STRING} and pattern: ^ref=([^=&]+)&JobPostingID=([^=&]+)$

Action : type: Rewrite and Rewrite URL: {C:1}/{C:2}

And it gave me new url string as

http://www.mySite.com/h_hj/10049

Now the problems are

1) I am unable to get query string values from URL as it is giving me problem during post back event as "Input string was not in a correct format."

 if (!string.IsNullOrEmpty(Request.QueryString["JobPostingID"]))
            return Convert.ToUInt32(Request.QueryString["JobPostingID"]);

2) How to hide referral query string parameters only from URL as "ref" in my case.

1
  • you need to get those value with Route data Commented May 4, 2012 at 7:09

1 Answer 1

1

Access your RouteData variable using RouteDataand Also refer this link Asp.net Routing

int JobPostID= Convert.ToInt32(Page.RouteData.Values["JobPostingID"]);
// do Some fun with your JobPostID
Sign up to request clarification or add additional context in comments.

1 Comment

Hey Thanx, but I am using url rewriting not routing, I used things you said and its giving error "Object reference not set to an instance of an object." as no value is assigning to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.