0

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:

window.location = "http://www.myapplication.org/Session/Enter?legacySessionId=fjD0pMTFTPFf6MgJZT0&RedirectPath=/Folio/OfflineDocument/EnqueueDocumentGenerationRequest/?FolderId=acf7egfsc0clz6ei&CourseId=vhvgyhgvhgvyy7yty"

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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");

Comments

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.