asp.net mvc的剃刀:如何直接访问.cshtml网页? [英] asp.net mvc razor: How to directly access .cshtml page?

查看:144
本文介绍了asp.net mvc的剃刀:如何直接访问.cshtml网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用直接剃刀视图引擎访问.cshtml文件中的ASP.NET MVC?

How can i directly access a .cshtml file in ASP.NET MVC using razor view engine?

例如,我有这个网址:本地主机/首页/。这将加载有关网站的主页面中。

For example i have this url: localhost/Home/About. This will load the about site inside the "master" page.

我想也没有加载母版页加载关于页面。所以我想,我可以用这个网址:本地主机/主页/ About.cshtml。但它不工作。

I want to load the about page without also loading the master page. So i was thinking that i could use this url: localhost/Home/About.cshtml. But it's not working.

如何加载一个视图页面,而无需加载母版页?

How can i load a view page without loading the master page?

推荐答案

您可以使用方法<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.html.partialextensions.partial%28v=vs.98%29.aspx\"相对=nofollow> Html.Partial 是这样的:

You can use the method Html.Partial like this:

@ Html.Partial(关于)

修改

我可能有missunderstood你的问题。如果你想避免,包括母版页,你需要删除的布局。

I might have missunderstood your question. If you want to avoid including the master page you need to remove the layout.

添加到您的视图的顶部:

Add this to the top of your View:

@{
     Layout = null;
 }

这篇关于asp.net mvc的剃刀:如何直接访问.cshtml网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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