asp.net 保存html文件,ASP.NET5.0添加html文件(ASP.NET5.0 Add html file)

ASP.NET5.0添加html文件(ASP.NET5.0 Add html file)

我有一个html文件index.html,我想与我的asp.net5项目链接。

我试图在wwwroot中添加index.html,当我开始调试时,我转到localhost:port / index.html,它没有显示任何内容。

有人可以链接到文档或解释如何做到这一点?

PS:我使用visual-studio。

配置代码:

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

public void Configure(IApplicationBuilder app)

{

app.UseIISPlatformHandler();

app.Run(async (context) =>

{

await context.Response.WriteAsync("test");

});

}

I got a html file index.html that i want to link with my asp.net5 project.

I have tried to add the index.html in wwwroot and when I start the debug I go to localhost:port/index.html and it shows me nothing.

Can some one link to a documentation or explain how to do it?

PS: I use visual-studio.

Config code:

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

public void Configure(IApplicationBuilder app)

{

app.UseIISPlatformHandler();

app.Run(async (context) =>

{

await context.Response.WriteAsync("test");

});

}

原文:https://stackoverflow.com/questions/37216793

更新时间:2019-11-10 06:32

最满意答案

您必须告诉应用程序您要使用静态文件。 例如,您不需要在Web Api 2.0服务器中使用它。 因此,默认情况下不会添加。 在你的Startup.cs中添加app.UseStaticFiles(); 到Configure方法。

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)

{

app.UseIISPlatformHandler();

app.UseStaticFiles();

app.UseMvc();

}

You have to tell the app that you want to use static files. You wouldn't need it in a Web Api 2.0 server for instance. So, this is not added by default. In your Startup.cs add app.UseStaticFiles(); to the Configure method.

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)

{

app.UseIISPlatformHandler();

app.UseStaticFiles();

app.UseMvc();

}

相关问答

您必须告诉应用程序您要使用静态文件。 例如,您不需要在Web Api 2.0服务器中使用它。 因此,默认情况下不会添加。 在你的Startup.cs中添加app.UseStaticFiles(); 到Configure方法。 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)

{

app.UseIISPlatformHandler(

...

我的工作在我身边。请试试这个: @{

ViewBag.Title = "Home Page";

Layout = null;

}

在你的代码中只需添加属性: protected void Page_Load(object sender, EventArgs e)

{

html_tag.Attributes.Add("xmlns:og","http://ogp.

...

确保你在没有调试的情况下启动项目(VS中的Ctrl + F5而不是F5)。 即时编译不适用于附加的调试器 Make sure you start the project without debugging (Ctrl + F5 in VS instead of F5). The compile on the fly doesn't work with a debugger attached

您的代码应如下所示:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值