【发布时间】:2016-08-02 16:45:39
【问题描述】:
我关注this example 创建了我的第一个Owin web page:
- 启动VS2013,创建Web应用的C#项目:
WebApplication1。 -
工具->Nuget包管理器->包管理器控制台
PM> Install-Package microsoft.owin.host.SystemWeb
我现在可以看到 owin 参考。 3、添加->新建项目->Owin启动类并输入代码sn-p:
using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(WebApplication1.Startup1))]
namespace WebApplication1
{
public class Startup1
{
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
app.Run(context =>
{
context.Response.ContentType = "text/plain";
return context.Response.WriteAsync("Hello, world.");
});
}
}
}
好的,现在我 Ctrl+F5 启动,它会打开一个 IE 浏览器。不幸的是,该页面显示 Web 应用程序内部存在一些错误:
HTTP 错误 403.14 - 禁止
Web 服务器配置为不列出此目录的内容。
最可能的原因: • 请求的 URL 未配置默认文档,服务器上未启用目录浏览。
您可以尝试的事情: •如果您不想启用目录浏览,请确保配置了默认文档并且该文件存在。 • 启用目录浏览。 1.转到 IIS Express 安装目录。 2.运行 appcmd set config /section:system.webServer/directoryBrowse /enabled:true 启用服务器级别的目录浏览。 3.运行appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true 启用站点级别的目录浏览。
•验证站点或应用程序配置文件中的 configuration/system.webServer/directoryBrowse@enabled 属性是否设置为 true。
详细错误信息:
模块 目录列表模块
通知 执行请求处理程序
处理程序 静态文件
错误代码 0x00000000
请求的网址 http://localhost:50598/
物理路径 D:\Documents\Visual Studio 2013\Projects\WebApplication1
匿名
登录用户 匿名
请求跟踪目录 D:\Documents\IISExpress\TraceLogFiles\WEBAPPLICATION1
更多信息: 如果未在 URL 中指定文档,未为网站或应用程序指定默认文档,并且未为网站或应用程序启用目录列表,则会发生此错误。为了保护服务器的内容,可能会故意禁用此设置。 查看更多信息 »
那么,我在所有步骤中是否遗漏或犯错了什么?如何让它发挥作用?
【问题讨论】:
-
你安装了 ASP.NET 吗?
Windows Features -> Internet Information Services -> World Wide Web Services -> Application Development Features -> ASP.NET x.x.
标签: c# asp.net owin webpage sample