Last post Apr 24, 2020 07:11 PM by emaak
Apr 23, 2020 06:56 PM|emaak|LINK
Hi ,im new to MVc.
tryying o simple login page dont have database with manual usernam and password wants to redirect page to welcom e page..Any suggestions
Apr 23, 2020 09:07 PM|PatriceSc|LINK
Not 100% sure about the exact problem. If you have no database at all and want to store hardcoded credentials you could have a look at http://geekswithblogs.net/AaronLi/archive/2007/02/20/106761.aspx (Forms
authentication, not the last part where credentials are stored directly in the web.config file).
You are uisng ASP.NET 4.x or ASP.NET Core? If ASP.NET Core you could use ASP.NET Identity.
All this may seem a bit more complex than "rolling" your own but the benefit iis that you can start with something simple (my understanding is that for now you don't even have a database where you could store credentials) but you'll be able to move the
app forward (as the app itselfy doesn't have to care where credentials are stored).
Apr 24, 2020 05:45 AM|Yongqing Yu|LINK
I made a simple example that only simulates redirecting to the home page after login.
Since there is no database, the login name and password are fixed in my example. However I still suggest that you use a database to log in, which will be more safer and more dynamic.
More details, you could refer to below code:
public class HomeController : Controller
//This is welcome page
public ActionResult Index()
public ActionResult Login()//Here you need to add the passed parameters
public ActionResult Login(String UserName,String Password)//Here you need to add the parameters
if (UserName=="11"&&Password=="11")//It is assumed here that the username and password are verified
ViewBag.Title = "Login";
<input type="submit" value="Login"/>
ViewBag.Title = "Home Page";
<h2>This is home page.</h2>
Here is the result.
Apr 24, 2020 06:08 PM|emaak|LINK
Thank you.Got it. its working now
Apr 24, 2020 07:11 PM|emaak|LINK
Thank you for the information.