2016-09-22 116 views
2

我已經發布了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); 
    } 
+1

是否有瀏覽器的開發者工具的任何網絡錯誤? (按F12 - >網絡選項卡) –

+0

您可以添加SearchController的代碼嗎? –

+0

您是否檢查用戶是否在SearchController中進行了身份驗證?因爲Login post方法中沒有任何內容表示用戶已經通過身份驗證。 –

回答

0

相信任何問題您的默認路由是登錄頁面。如果你改變它,這是否解決了這個問題?

app.UseMvc(routes => 
{ 
    routes.MapRoute(
     name: "default", 
     template: "{controller=Home}/{action=Get}/{id?}"); 
}); 

(請務必立即更換首頁&使用默認頁取得)

+0

它沒有幫助me.my控制器是「LoginController」,操作是「登錄」 – KrishOnline

+0

但是,您的應用程序主頁的控制器是什麼? –

+0

這是爲成功登錄而發生的 return RedirectToActionPermanent(「Index」,「Search」); 主頁 - SearchController和操作是索引 – KrishOnline