Reputation: 1719
I have a method written in my controller. I am passing values to this controller as querystring. The sample url to that controller method is:
My controller method has following definition:
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Enter(
string legacySessionId,
string RedirectPath,
string siteSubdomain = "",
bool isDuplicate = false,
int id = 0
)
Inside this controller method when I get the querystring value for RedirectPath it only gives:
RedirectPath="/Folio/OfflineDocument/EnqueueDocumentGenerationRequest/?FolderId=acf7egfsc0clz6ei"
Whereas the expected result is :
RedirectPath="/Folio/OfflineDocument/EnqueueDocumentGenerationRequest/?FolderId=acf7egfsc0clz6ei&CourseId=vhvgyhgvhgvyy7yty"
It is missing "CourseId" part. Can someone point out the issue?
Upvotes: 0
Views: 165
Reputation: 163
You need to escape ampersand in parameter. Just encode that parameter value.
window.location = "http://localhost:13203/Home/Enter?legacySessionId=fjD0pMTFTPFf6MgJZT0&RedirectPath="
+ encodeURIComponent("/Folio/OfflineDocument/EnqueueDocumentGenerationRequest/?FolderId=acf7egfsc0clz6ei&CourseId=vhvgyhgvhgvyy7yty");
Upvotes: 1
Reputation: 37660
You have to encode the ampersand char:
& ==> &
To will be:
window.location = "http://www.myapplication.org/Session/Enter?legacySessionId=fjD0pMTFTPFf6MgJZT0&RedirectPath=/Folio/OfflineDocument/EnqueueDocumentGenerationRequest/?FolderId=acf7egfsc0clz6ei&CourseId=vhvgyhgvhgvyy7yty"
&
is the separator of arguments in the url. If this char is part of the value, it has to be encoded.
Upvotes: 1