南希:从&QUOT提供静态内容(例如,index.html); /"? [英] Nancy: Serving static content (e.g. index.html) from "/"?

查看:214
本文介绍了南希:从&QUOT提供静态内容(例如,index.html); /"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让南希用一个页面的Web应用程序。因此,我希望我的根URL服务于一个普通的.html文件,没有任何视图逻辑或任何责任。

I'm trying to make a single page web application using Nancy. Therefore, I want my root URL to serve a plain .html file, without any view logic or whatsoever.

我试过

Get["/"] = parameters => Response.AsHtml("content/index.html")



但是,没有任何 AsHtml

我试着用

conventions.StaticContentsConventions.Add(
    StaticContentConventionBuilder.AddFile("/", @"content/index.html")
);



但很显然它认为/不是一个文件 - 南希给了我一个目录列表上的http://本地主机:<港口> / 而不是

我该怎么办?这不应该这么难吧?

What do I do? This shouldn't be this hard, right?

PS。任何方式把该目录列出了吗? ,感觉不安全。

ps. Any way to turn that directory listing off? It feels insecure.

推荐答案

只要把你的意见文件夹,并做到:

Just put it your views folder and do:

Get["/"] = _ => View["index"];



目录列表无关南希,无论托管你使用的是一个查看。

The directory listing is nothing to do with Nancy, whatever hosting you're using is displaying that.

这篇关于南希:从&QUOT提供静态内容(例如,index.html); /&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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