使用ASP.NET,如何可靠地从给定字符串中剥离HTML标记(即不使用正则表达式)?我正在寻找像PHP这样的东西strip_tags
.
<ul><li>Hello</li></ul>
"你好"
我试图不重新发明轮子,但到目前为止我还没有找到满足我需求的东西.
使用App_GlobalResources目录中的resx文件,我已经能够更改模型验证器的PropertyValueInvalid字符串的默认消息.
但是当需要值时,它无法转换消息(PropertyValueRequired.)
在Global.asax.cs Application_Start()中,我更改了资源类键,如下所示:
DefaultModelBinder.ResourceClassKey = "Messages";
Run Code Online (Sandbox Code Playgroud)
在Messages.resx文件中,我放了两个条目:
谢谢.
我的意思是,现在我们已经尽可能地使用现代模板引擎将你的html标记与你的代码分开了(在过去,程序员通常只是在php中连接字符串,这很糟糕.)
然后我看一下同事生成一个html表的代码,它看起来像:
<% Html.Grid(Model).Columns(column => {
column.For(x => Html.ActionLink("Edit", "Edit", new { id = x.Id })).Attributes(width => "30px").DoNotEncode();
column.For(x => Html.ActionLink("Delete", "Delete", new { id = x.Id }, new { @class = "delete" })).Attributes(width => "95px").DoNotEncode();
column.For(x => x.Id).Named("Code");
column.For(x => x.Name).Named("Name").HeaderAttributes(align => "left");
column.For(x => x.CPF).Named("CPF");
})
.Attributes(width => "100%", border => "0", cellpadding => "0", cellspacing => "0", @class => "data-table")
.Empty("No users found!")
.RowStart(row => string.Format("<tr class='row{0}'>", row.IsAlternate ? "-alternating" : ""))
.Render();
%>
Run Code Online (Sandbox Code Playgroud)
他认为这很棒,我认为这很难看,所以我想知道更多人的意见.
我们最近丢失了一个数据库,我想从de Production.log中恢复数据。
每个请求都是这样记录的:
处理ChamadosController#create(对于XXX.XXX.XXX.40,在2008-07-30 11:07:30)[POST]会话ID:74c865cefa0fdd96b4e4422497b828f9参数:{“ commit” =>“ Gravar”,“ action” =>“ create”,“ funcionario” =>“ 6” ...(所有其他参数都在此处)。
但是会话中有一些要发布到数据库上的东西。在请求中,我具有会话ID,并且还具有服务器中的所有会话文件。
无论如何,我可以通过此会话ID打开会话文件并获取其内容吗?
asp.net-mvc ×2
asp.net ×1
c# ×1
coding-style ×1
html ×1
mvccontrib ×1
regex ×1
session ×1
string ×1