英文:
how can I change asp.net core 6 wwwroot folder path to another server
问题
我面临这种情况,客户希望在服务器上设置IIS,将SQL Server放在另一台服务器上,并将上传的文件放在另一台服务器上。
所有服务器都连接到本地网络,只有IIS服务器连接到互联网。
那么,我应该如何将ASP.NET Core 6的wwwroot文件夹路径更改为另一台服务器?
我尝试将网络文件夹创建快捷方式放在wwwroot中,但它看起来更像是一个.link文件而不是文件夹。
英文:
I'm facing this situation, the customer wants to set the IIS on server , SQL Server on other server and uploaded files on other server.
all servers linked in local network , IIS server connected to the internet only.
so how can I change asp.net core 6 wwwroot folder path to another server?
I tried to set shortcut of a network folder in the wwwroot but it's look like a .link not a folder
答案1
得分: -1
为解决这个问题,请添加以下代码:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(@"\2.168.1.234\Arc\Uploaded\"),
});
在调试模式下,这可以正常工作,但在发布时会出现以下错误:
HTTP Error 500.30 - ASP.NET Core 应用程序启动失败
要解决这个问题,请在IIS中添加帐户:
- 打开IIS管理器
- 打开应用程序池 -> 选择要更改的应用程序池
- 右键单击应用程序池,选择高级设置
- 选择“身份”列表项,然后单击省略号(带有三个点的按钮)
- 选择自定义帐户 -> 设置...
- 输入用户名:
<machinename> 和相关密码 - 确定,确定,确定...
英文:
to solved this issue add:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider("\\\2.168.1.234\\Arc\\Uploaded\\"),
});
this work fine in debug mode, in publish gives this error:
> HTTP Error 500.30 - ASP.NET Core app failed to start
to solve it add account in IIS:
- Open the IIS Management
- Open the Application Pools ->Select the application pool you want
to change - Right click the application pool and select Advanced Settings
- Select the Identity list item and click the ellipsis (the button
with the three dots) - Select the custom account -> set...
- insert user name: <domainname><machinename> and related password
- ok , ok ,ok ...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论