How do you set the content type for a WebMatrix/Razor Response?

后端 未结 3 1403
你的背包
你的背包 2021-02-19 00:48

I\'d like to return some XML instead of HTML in my WebMatrix cshtml file? How do you change the content type header?

3条回答
  •  抹茶落季
    2021-02-19 01:13

    Use the Response.ContentType property at the top of your .cshtml file then include the XML in the content of the view:

    @{ 
       Response.ContentType = "application/xml";
    }
    
    
        415-123-4567
    
    

提交回复
热议问题