开发者

Problem by Url.Action in asp.net MVC

开发者 https://www.devze.com 2023-03-13 23:11 出处:网络
I have a problem by Url.Action in asp.net MVC. this is a sample: Url.Action(\"index\", new { page = 1, success = 2});

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消