简体   繁体   English

VS2017:为什么 razor 项目仍然指的是 MVC?

[英]VS2017: Why razor project still refers to MVC?

I'm very confused about MVC and razor projects for ASP.NET Core 2.0.我对 ASP.NET Core 2.0 的 MVC 和 razor 项目非常困惑。 In Visual Studio 2017 I do the following:在 Visual Studio 2017 中,我执行以下操作:

  • New project新项目
  • Web ASP.NET Core Application (C#) Web ASP.NET 核心应用程序 (C#)
  • Web Application (NOT Web Application MVC) Web 应用程序(不是 Web 应用程序 MVC)

But when I open the cs code of a page I see:但是当我打开页面的 cs 代码时,我看到:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;  // <------- MVC?

namespace WebApplication2.Pages
{
    public class AboutModel : PageModel
    {
        public string Message { get; set; }

        public void OnGet()
        {
            Message = "Your application description page.";
        }
    }
}

Why it still refers to MVC if I selected a razor only project?如果我选择了一个 razor only 项目,为什么它仍然指的是 MVC?

My question rises from a deeper problem: I don't understand what documentation I have to follow!我的问题来自一个更深层次的问题:我不明白我必须遵循什么文档! When I see a tutorial about razor or MVC I'm not sure if it applies to this type of project.当我看到有关 razor 或 MVC 的教程时,我不确定它是否适用于此类项目。

This is simply because the Microsoft.AspNetCore.Mvc namespace is where the microsoft team decided to put Razor.这仅仅是因为Microsoft.AspNetCore.Mvc命名空间是微软团队决定放置 Razor 的地方。 It doesn't mean that your project uses MVC, just that some classes it uses are located in a namespace that contains MVC in its name.这并不意味着您的项目使用 MVC,只是它使用的某些类位于名称中包含MVC的命名空间中。

It is just a guess, but I believe it could simply be a historic thing.这只是一个猜测,但我相信这可能只是一个历史性的事情。 Razor used to really be just part of MVC, so it was under the MVC namespace but now that it doesn't need MVC to live they left it here for compatibility or consistency ? Razor 曾经真的只是 MVC 的一部分,所以它在 MVC 命名空间下,但现在它不需要 MVC 来生存,他们将它留在这里是为了兼容性或一致性? This question can probably only be answered by someone from microsoft :-/这个问题可能只能由微软的人回答:-/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM