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.

4

1 回答 1

1

使用RouteData访问您的 RouteData 变量,另请参阅此链接Asp.net Routing

int JobPostID= Convert.ToInt32(Page.RouteData.Values["JobPostingID"]);
// do Some fun with your JobPostID
于 2012-05-04T07:11:55.093 回答