.net core webapi 将localhost改成ip地址

 

用管理员身份运行vs

添加引用

using Microsoft.AspNetCore.Cors;

修改

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCors(builder =>
{
builder.AllowAnyHeader();
builder.AllowAnyMethod();
builder.AllowAnyOrigin();
});

 

app.UseMvc();
}

修改c盘host文件C:\Windows\System32\drivers\etc

# localhost name resolution is handled within DNS itself.
# IP地址    localhost
# 127.0.0.1 localhost
# ::1 localhost

---cmd 运行  ipconfig /flushdns

 

转载于:https://www.cnblogs.com/zhang-wenbin/p/9208453.html

你可能感兴趣的:(.net core webapi 将localhost改成ip地址)