如何设置WebMatrix / Razor响应的内容类型? [英] How do you set the content type for a WebMatrix/Razor Response?

查看:78
本文介绍了如何设置WebMatrix / Razor响应的内容类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在WebMatrix cshtml文件中返回一些XML而不是HTML吗?如何更改内容类型标题?

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

推荐答案

使用.cshtml文件顶部的Response.ContentType属性,然后包括视图内容中的XML:

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";
}
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial>415-123-4567</Dial>
</Response>

这篇关于如何设置WebMatrix / Razor响应的内容类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆