如果我的模特有
[DisplayName("First Name")]
public string firstName { get; set; }
Run Code Online (Sandbox Code Playgroud)
然后我可以在View with LabelFor中打印它
@Html.LabelFor(model => model.acc_first)
Run Code Online (Sandbox Code Playgroud)
它将呈现为
<label for="firstName">First Name</label>
Run Code Online (Sandbox Code Playgroud)
如何在没有HTML编码的情况下渲染我的选择列表
@{
var noiceList = new SelectList(new[] { new {ID = "", Name = ""},
new {ID = "y", Name = "Yes after3Space"},
"ID", "Name");
}
@Html.DropDownList("noice", @noiceList )
Run Code Online (Sandbox Code Playgroud)
呈现
..
<option value="y">Yes&nbsp;&nbsp;&nbsp;3Space</option>
...
Run Code Online (Sandbox Code Playgroud)
如何让它代替渲染
<option value="y">Yes after3Space</option>
Run Code Online (Sandbox Code Playgroud) 部署ASP.NET MVC 4 Web API时出现问题
我尝试部署ASP.NET MVC 4 Web API站点.一切正常但如果我从外部调用服务器并返回400及以上的HTTP状态,Web服务器将接管响应.
在服务器上本地调用工作正常.
例:
Work fine:
http:// myTestServer.se/Test/api/Test/200
http:// myTestServer.se/Test/api/Test/399
Does not work, the Web server takes over the response:
http:// myTestServer.se/Test/api/Test/400
http:// myTestServer.se/Test/api/Test/599
For those cases where there is an Error Pages is returned. For an invalid code is returned ”The custom error module does not recognize this error.”
if I make the calls locally on the server, it works fine:
http://localhost/Test/api/Test/400
http://localhost/Test/api/Test/599
Run Code Online (Sandbox Code Playgroud)
我的简单测试代码会将收到的ID作为HTTP状态返回.
// GET /api/values/200
public HttpResponseMessage<string> Get(int id) …
Run Code Online (Sandbox Code Playgroud)