3

I have a problem by Url.Action in asp.net MVC. this is a sample:

Url.Action("index", new { page = 1, success = 2});

This code generate this url index?page=1&success=2 In this url there is & instead of & character. because of this problem Request.QueryString["success"] return null. What is the solution? Note: Im using Url.Action and Request.QueryString in a view not a controller.

2 Answers 2

4

Problem is encoding

You're probably using <%: %> but you should be using <%= %> so result will not get encoded.

So instead of writing:

<a href="<%: Url.Action("index", new { page = 1, success = 2}) %>">My link</a>

you should convert to:

<a href="<%= Url.Action("index", new { page = 1, success = 2}) %>">My link</a>
Sign up to request clarification or add additional context in comments.

Comments

1

You are probably html-encoding the output of the Url.Action.

Can you post code about where and how you use the result? Because the method itself should return the value as you expect it.

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.