Heba Heba - 1 year ago 68
C# Question

Why my app opens empty page and doesn't go to any redirect link after route page?

Why my app opens empty page and doesn't go to any redirect link after route page ??
I work on C# , MVC , Visual studio 2010

this is my login action:

public ActionResult Login()
return View();

public ActionResult Login(string name, string psw)
if ((Membership.ValidateUser(name, psw)) == true)
FormsAuthentication.SetAuthCookie(name, false);
if ((Roles.IsUserInRole(name, "Admin")) == true)
return this.RedirectToAction("AboutDetails_Admin", "mytask");

else if ((Roles.IsUserInRole(name, "People")) == true)
return this.RedirectToAction("TMembersDetails_Admin", "mytask");
else return View();
else return this.RedirectToAction("Register", "Default");

and this is the login view:

ViewBag.Title = "Login";
Layout = "~/Views/_LayoutPage1.cshtml";


<form action="/Default/Login" method="post">
<label>Full Name:</label><input type="text" name="name" /><br />

<label>Password:</label><input type="text" name="psw" /><br />

<input type="submit" />


this is my web.config :

enter code here

<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="ttt" />

<add key="webpages:Enabled" value="false" />

<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />

<add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

and this is my route:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace ttt
public class RouteConfig
public static void RegisterRoutes(RouteCollection routes)

name: "Default",
url: "",
defaults: new { controller = "Default", action = "Index",
id = UrlParameter.Optional }

what can I do to make my index page redirect to the login page and not open empty page with http://localhost:1889/Default/Login

Answer Source

I found the mistake , in the first in visual studio 2015 when I choosed new project It make the the project Authentication : individual by default , so it resultd empty pages when project run .. when I change authentication (in the first) to No authentication so it works now.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download