如何在MVC(Razor)中编码和解码值 [英] How to Encode and Decode Values in MVC (Razor)
问题描述
Hello Everybody,
我正在使用MVC3中的Razor设计模式。在那里我想编码url以将值传递给另一个表单。
例如:
您可能有一个删除注释操作你的CommentController采用CommentID。动作网址可能看起来像是/ Comments / Delete / 3来删除ID为3的评论。
现在还有一个问题关于相同的主题是如何解码它编码。因为在asp.net中我们可以通过将字符串拆分来做到这一点。
需要支持..
使用Razor会自动进行html编码。您可以使用@ Html.Raw(文本)来避免它。
祝你好运!
使用以下语句进行编码&解码:
语法:
@ Ajax.JavaScriptStringEncode(@ sharePointDocument.URL)
作者:Mahender Swamy
Hello Everybody,
I am working with Razor design pattern in MVC3. There I want to encode the url to Pass the values to another form.
For Example :
you might have a Delete Comment action on your CommentController which takes a CommentID. The action url might look like /Comments/Delete/3 to delete the comment with the id 3.
Now there is another question regarding same topic is that how to decode if it encoded . Because in asp.net we can be do that by split the string by ?.
Need Support..
With Razor all is automatically html encoded. You can use @Html.Raw(text) to avoid it.
Good luck!
use the following statement to encode & decode :
Syntax :
@Ajax.JavaScriptStringEncode(@sharePointDocument.URL)
By Mahender Swamy
这篇关于如何在MVC(Razor)中编码和解码值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!