我已經發布了asp.net核心1.0應用程序到IIS版本8.5作爲一個新的網站。 我只能看到登錄頁面。成功登錄後,獲取空白頁面。也許路由不工作perfectly.I沒有運行該應用程序在我開發machine.see我的配置和啓動ASP.NET核心發佈到IIS空白加載屏幕
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseApplicationInsightsRequestTelemetry();
app.UseSession();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseApplicationInsightsExceptionTelemetry();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Login}/{action=Login}/{id?}");
});
}
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
登錄控制器
public class LoginController : Controller
{
private StaunchContext _context;
public LoginController(StaunchContext context)
{
_context = context;
}
// GET: /<controller>/
public IActionResult Login()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Login(UserDetails users)
{
if (ModelState.IsValid)
{
var exist =await _context.UserDetails.SingleOrDefaultAsync(x => x.Email == users.Email && x.Password == users.Password);
if ((exist!=null)&& exist.Id > 0)
{
TempData["Users"] = JsonConvert.SerializeObject(exist);
HttpContext.Session.SetString("Email", exist.Email);
return RedirectToActionPermanent("Index", "Search");
}
else
{
ModelState.AddModelError("loginerror", "Invalid username or password");
}
}
return View(users);
}
是否有瀏覽器的開發者工具的任何網絡錯誤? (按F12 - >網絡選項卡) –
您可以添加SearchController的代碼嗎? –
您是否檢查用戶是否在SearchController中進行了身份驗證?因爲Login post方法中沒有任何內容表示用戶已經通過身份驗證。 –