Razor视图生成XML第一行是空行
{
Layout = null;
Response.ContentType = "application/xrds+xml";
}
<?xml version="1.0" encoding="UTF-8" ?>
<xrds:xrds xmlns:xrds="xri://$xrds"
xmlns:openid="http://openid.net/xmlns/1.0"
xmlns="xri://$xrd*($v*2.0)">
<xrd>
<service priority="10">
<type>http://specs.openid.net/auth/2.0/server</type>
<type>http://openid.net/extensions/sreg/1.1</type>
<uri>@(new Uri(Request.Url, Response.ApplyAppPathModifier("~/home/contact")))</uri>
</service>
</xrd>
</xrds:xrds>
使用DotNetOpenAuth,把aspx页面换成Razor页面,上面的View输出一个XML,总是在第一行是空行,客户端各种报错,最后翻了墙才搜出,原来是Razor的Bug,
原文:http://stackoverflow.com/questions/3190584/how-do-you-set-the-content-type-for-a-webmatrix-razor-response
最后解决:http://devstuffs.wordpress.com/2014/02/07/first-line-empty-in-razor/

浙公网安备 33010602011771号