为此在&QUOT路由请求; .cshtml"到控制器 [英] Routing requests that end in ".cshtml" to a controller

查看:195
本文介绍了为此在&QUOT路由请求; .cshtml"到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(这是交叉贴到ASP.NET表单)

(This is cross-posted to the ASP.NET forms)

我工作的 WebGit .NET 项目,我们是接近1.0发布。然而,我无法让我的浏览控制器(拉文件从存储库)担任-UP.cshtml文件。

I'm working on the WebGit .NET project, and we are close to a "1.0" release. However, I'm having trouble getting my "Browse" controller (which pulls files out of the repository) to serve-up ".cshtml" files.

我本来用的.config和的.cs文件的麻烦为好,但我的固定与此在web.config中:

I originally had trouble with ".config" and ".cs" files as well, but I fixed that with this in the web.config:

  <location path="browse">
    <system.webServer>
      <security>
        <requestFiltering>
          <fileExtensions allowUnlisted="true">
            <clear />
          </fileExtensions>
          <hiddenSegments>
            <clear />
          </hiddenSegments>
        </requestFiltering>
      </security>
    </system.webServer>
  </location>

这应该处理这个请求(即成功路由一切)路由是:

The routing that should be handling this request (that is successfully routing everything else) is:

routes.MapRoute(
    "View Blob",
    "browse/{repo}/blob/{object}/{*path}",
    new { controller = "Browse", action = "ViewBlob", path = UrlParameter.Optional });

现在,每当我尝试访问,在.cshtml结尾的网址,它提供了404,即使我的要求应该已经通过浏览控制器处理。这些文件我服务行动在磁盘上不存在,但可以从一个Gi​​t仓库的斑点拉。我已经尝试过所有其他文件扩展名的作品就好。

Now, whenever I try to access a URL that ends in ".cshtml", it gives a 404, even though my request should have been handled by the "Browse" controller. The files I'm serving-up do not exist on disk, but are instead pulled from a git repository as blobs. Every other file extension that I have tried works just fine.

我怎样才能解决这个问题?

How can I fix this behavior?



修改我试图禁用的网页像这样:


I have tried disabling WebPages like so:

<appSettings>
  <add key="webpages:Enabled" value="false" />
</appSettings>

但似乎没有任何效果。

But that appears to have no effect.

推荐答案

作为一个快速的解决方法,你可以在你的应用程序的根把一个临时browse.cshtml文件,并把这个你的web.config里面,
添加关键=网页:启用VALUE =FALSE

As a quick workaround, you can put a temporary browse.cshtml file at your application root and put this inside your web.config, add key="webpages:Enabled" value="false"

这篇关于为此在&QUOT路由请求; .cshtml&QUOT;到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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