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.
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>
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.
精彩评论