C# ASP.NetCore 2.1给出了HTTP404:未找到服务器未找到任何与请求的URI(统一资源标识符)匹配的内容
我用MVC.netcore 2.1构建了一个测试网站,该网站在开发过程中运行良好,并在本地IIS上发布。当我运行发布的网站时,它会显示登录页面,但在获取用户和密码后,它会显示空白页面,而不是主页。我不知道是什么错误,任何帮助将不胜感激 通过检查F12,发现以下错误消息: 在IE边缘中 “HTTP404:未找到-服务器未找到任何与请求的URI(统一资源标识符)匹配的内容。 张贴— 在Firefox中: “未声明纯文本文档的字符编码。如果文档包含US-ASCII范围之外的字符,则在某些浏览器配置中,文档将以乱码文本呈现。文件的字符编码需要在传输协议中声明,或者文件需要使用字节顺序标记作为编码咬人。”C# ASP.NetCore 2.1给出了HTTP404:未找到服务器未找到任何与请求的URI(统一资源标识符)匹配的内容,c#,asp.net-core-2.1,C#,Asp.net Core 2.1,我用MVC.netcore 2.1构建了一个测试网站,该网站在开发过程中运行良好,并在本地IIS上发布。当我运行发布的网站时,它会显示登录页面,但在获取用户和密码后,它会显示空白页面,而不是主页。我不知道是什么错误,任何帮助将不胜感激 通过检查F12,发现以下错误消息: 在IE边缘中 “HTTP404:未找到-服务器未找到任何与请求的URI(统一资源标识符)匹配的内容。 张贴— 在Firefox中: “未声明纯文本文档的字符编码。如果文档包含US-ASCII范围之外的字符,则在某些浏览器配置中,
谢谢您是否通过邮递员、失眠或其他rest客户端尝试过相同的Uri。我觉得Firefox打了一个GET电话,IE打了一个POST电话。还可以共享一些控制器端点代码和您的请求详细信息。@Ram Kumaran,我没有尝试通过邮递员,但我没有使用任何API,如果用户详细信息有效,请重定向到主控制器,否则请与错误消息保持在同一页。共享startup@RamStartup.cs成为问题。请看一看。也共享帐户控制器代码。默认控制器配置为帐户控制器。
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, ApplicationRole>(options => options.Stores.MaxLengthForKeys = 128)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultUI()
.AddDefaultTokenProviders();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Account}/{action=Index}/{id?}");
});
AutoMapper.Mapper.Initialize( x=>x.AddProfile<ProfileMappings>());
}
}
[HttpPost]
public IActionResult Index(AccountLoginModel model)
{
if (ModelState.IsValid)
{
var user = Task.Run(async () => await userManager.FindByEmailAsync(model.Email)).Result;
if (user != null && user.IsEnabled)
{
var result = repository.SignIn(model.Email, model.Password).Result;
if (result.Succeeded)
{
return RedirectToAction("Index", "Home");
}
ModelState.AddModelError("CustomError", "Username or/and Password is invalid.");
}
else
{
ModelState.AddModelError("CustomError", "Username or/and Password is invalid.");
}
}
return View(model);
}