WebMatrix cshtmlファイルでHTMLの代わりにXMLを返したいですか?コンテンツタイプヘッダーをどのように変更しますか?
			
			4233 次
		
3 に答える
            24        
        
		
.cshtmlファイルの上部にあるResponse.ContentTypeプロパティを使用して、ビューのコンテンツにXMLを含めます。
@{ 
   Response.ContentType = "application/xml";
}
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial>415-123-4567</Dial>
</Response>
于 2010-07-06T22:07:48.787   に答える
    
    
            19        
        
		
Razorファイルの先頭で、ResponseオブジェクトのContentTypeを設定します。
@{
  Response.ContentType = "application/xml";
}
... xml here ...
于 2011-01-20T04:05:58.390   に答える
    
    
            0        
        
		
ASP.NET MVCを使用している場合は、次のように、コントローラーのアクションメソッドを変更することを選択できます。
public ActionResult MyAction() {
    Response.ContentType = "text/xml";
    return View();
}
于 2012-01-16T22:56:40.653   に答える