Here is the Video link for new video for custom login & registration using Asp.Net Core: th-cam.com/video/712G-iQ1zzg/w-d-xo.html. Thanks all for your positive comments. I have seen many people are saying that they are facing "The name Session doesnot exist in the current context" error. In most cases this error comes when session is not available. This video was created with Asp.Net MVC using .Net Framework 4.6. In case, if you are using .Net 6/Core MVC version, then session usage is little bit different. So if you are using .Net 6, then try to use HttpContext.Session.SetString("UserId") instead of Session["UserId"] and so on. Although you can face some other issues, as these two .Net Framework versions are different.
Thanks for making such video, It is very informative video, plz make it for multi roles like "Admin, User, Accountant, Storekeeper" with own areas......
@@kubraaydn3451 you can add angularjs by adding its script file in applications and then add the link of that file in the page you want to use AngularJS
As a starting point it works... but i will NEVER use this kind of login/registration in a real application working in production.. passwords and not hashed and there are a lot of issues, for example.. how to restrict "non registered" users from viewing a page. OWIN offers a better way to do this but it is really complex and i'm still looking for a good tutorial that does not REQUIRES me to create a new ASP.NET MVC App, since i have a working application and i need to implement user validation.
I create login page as you have shown in this video no error working fine the only thing I can not see is data into my database table can you please let me know what I have done wrong??? I rally want to do it ASAP thanks
I do have a question though, how come he didnt do enable-migration since a declaration must be made first and according to my knowledge, using entity framework requires you to do the following first before moving to controllers: 1- enable-migrations 2- add-migration 3- update-database he didnt do any of that, does that mean the process of migration can be done automatically by visual studio? please someone clarify this point for me
Hi thanks for sharing the tutorial. Just one issue. Where can find the database table? The account data should be recorded somewhere, but i cannot find it. Does anybody find this issue?
DbContext class is provided by Entity Framework. We inherit our database context class from DbContext. Our Database context class contains all mapping of tables and relation between them.
The users have to register himself with the site before using the functionality. After registrations user id and password will be provided to the user. Through which he can login. first step ye hai is me kya krna hai kch pta hai
+Jigyasu pokhrel You can merge this with your own database simply by adding properties for these classes in your database context class, just like we did at 06:18 in this tutorial. Thanks.
@@RoshelJudithYou have to choices: 1. Use Identity and it will automatically generate code required for register, login and many more actions. 2. Instead of Session, use Viewbag to pass the data to the view.
Thanks, Make sure you have added validation summary on the view. Also wrap the login login in try catch and in catch add the same error, because sometimes .single gives error, or instead of .single you can use .where(u => u.Username == user.Username && u.Password == user.Password).FirstOrDefault().
I tried this, how come login button doesnt work, login controller had httppost login(User user) and exact code and when clicking login it does nothing? hmm..
Something which you have not tested is what if the password or email are wrong ? this gives an error where you never condition if the password or email are incorrect
+Thang Nguyen Van No, if you are following this tutorial then there is no need to create SQL Server connection. Entity framework will take care of it automatically and it will create a local database for you behind the scene. You can see that database in your users directory.
+Thang Nguyen Van you have to make an object of account class then reassign the data of your account parameter to it. After that you can add. Eg: UserAccount newUserAccount = new UserAccount(); newUserAccount.Firstname = account.FirstName; ( or what ever your fields are) db.userAccount.Add(newUserAccount);
I have created a new page where I'm inserting and getting data from the database.Now getting an error (are you missing a using directive or an assembly reference?) I checked everything but this error is not going. public DbSet pc_UPC { get; set; } public DbSet pc_INTERMEDIATE { get; set; }
It's looks like you have not used entity framework reference in the file. Make sure entity framework is imported at the top of this file. If not solved then share you code.
public MotorcraftContext() : base("name=Test_TrainingEntities") { } public DbSet Overpack_I_2_OF_5_BARCODE { get; set; } public DbSet pc_UPC { get; set; } public DbSet pc_INTERMEDIATE {get; set; } I added Context name then it worked but again I'm getting error The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. I am tired now dont know what to do
Megha Misra I knw it's late but if u haven't found d solution and still have tht bug in mind about why it happened ()- have u checked that all ur tables been created or not ? if not than try out migrations and declare ConnectionString inside base() in context file. and then mention it in WebConfig file
you can create a method that will confirm this and inside the method all you have to do is run: bool UserExists = db.userAccounts.Any(x => x.Username == user.username) It will return a true/false whether the database table userAccounts contains or doesn't contain a row where UserName column contains the username from the model (user.username) Same procedure is for the E-mail.
Here is the Video link for new video for custom login & registration using Asp.Net Core: th-cam.com/video/712G-iQ1zzg/w-d-xo.html.
Thanks all for your positive comments. I have seen many people are saying that they are facing "The name Session doesnot exist in the current context" error. In most cases this error comes when session is not available. This video was created with Asp.Net MVC using .Net Framework 4.6. In case, if you are using .Net 6/Core MVC version, then session usage is little bit different. So if you are using .Net 6, then try to use HttpContext.Session.SetString("UserId") instead of Session["UserId"] and so on. Although you can face some other issues, as these two .Net Framework versions are different.
I found this video very useful. I am just starting to learn MVC so it has given me a great starting point. Thanks for taking the time to post this.
Thanks and welcome.
Hi ! I did in this video. How do I add AngularJs to the client side?
@@OpenEducationChannel Hi ! I did in this video. How do I add AngularJs to the client side?
Thanks for making such video, It is very informative video, plz make it for multi roles like "Admin, User, Accountant, Storekeeper" with own areas......
Still works 100% in Visual Studio 2019 using newer methods and whatnot
SO thankful for this video. It is great and so easy to follow. Please post more MVC videos.
Thai Vuong .
Very useful tutorial for beginners....gr8 stuff...thank you
Really Nice... Explanation... i setup my app using your instructions.
Thank you, it is very useful. Enjoy on it
Congratulations, simple and objective
Thank you very very much for you clear instructions .. It was very help full.
ThankYou So much It Is very Help full For Mee GoodJob..
i will be forever gratefull for this tutorial
Love you from india
thanks a lot for this tutorial it's helped me very much
Excellent, found it very useful and helped "demystify" MVC :)
How can it connect database ? I want to database and table with ef code first ...
Fantastic knowledge. Can You Explain How to Connect Existing SQL DATABase register table...
That would be great if you include the log out feature. :)
But anyway, thanks for your tutorial. Problem solved. :)
How can it connect database ? I want to database and table with ef code first ...
it's a great video, but I really appreciate if you could show us how to make this login connected from the database
Thanks a lot.......its easily understandable
Very useful.thank you for sharing
Simple explanation, thanks
so nice tutorial ,thanks
Thanks so much for your time and consideration in this matter
Thank you so much for this video you helped me tremendously!
Thank you sirrr
Very useful tutorial. Thank you man!
How can it connect database ? I want to database and table with ef code first ...
thanks for share knowledge
Very2 helpfull
Excellent tutorial, worked perfect for me!! :)
so helpful but how do you get the data to go into the database im kinda new to this stuff
Hi ! I did in this video. How do I add AngularJs to the client side?
this is amazingly simple. Thank you for this.
I need a help sir.can u send a gmail and password format which can be given in registration page this is the error which I am facing a lot
Hi ! I did in this video. How do I add AngularJs to the client side?
Thank you helps me a lot.
thanks so much you helped a lot, great tutorial
it worked perfectly, i can do the modifications for the rest thanks :)
Hi ! I did in this video. How do I add AngularJs to the client side?
@@kubraaydn3451 you can add angularjs by adding its script file in applications and then add the link of that file in the page you want to use AngularJS
Great tutorial! Thanks alot.
Thank you for very usefull infos :)
thank you for the video sir
in my opinion, Session[""]=user..ToString() should be changed that: HttpContext.Session.GetString("").In my case, i fixed those bugs.
When i clic in the login button que app does not doing nothing. just stay in login. where i can find the bug ?
Excellent video!!
You do grate, thanks
Greate tutorial
Thank you great tutorial
This is very clean and good tutorial but not recommended for bigenners
very good ....!
Brilliant tutorial ^_^ Thank you
very good
Thanks for the tutorial :)
Thanks so much man!
Great tutorial!!!
Can you publish the project?
How can it connect database ? I want to database and table with ef code first ...
Nice, but can uoy try to make it with a Mysql insted so it bee more autentick
Thanks man.
thank u so much!
Thank you Sir.
Thank you!
Thanks for this tutorial but How we can see database is created any tool ? and how can upload this project with database on Server ?
nice tuto
Why do we need 2 (overloaded) functions for register and login?
super....
If I use DB first, How can I add validation data annotations for each attributes of a table ?
thanks buddy
As a starting point it works... but i will NEVER use this kind of login/registration in a real application working in production.. passwords and not hashed and there are a lot of issues, for example.. how to restrict "non registered" users from viewing a page. OWIN offers a better way to do this but it is really complex and i'm still looking for a good tutorial that does not REQUIRES me to create a new ASP.NET MVC App, since i have a working application and i need to implement user validation.
hay , excellent !next time add the code :)
+avi balulu ok sure. :)
How to use the MVC own Login and redirect to DashBoard?
Thanks Bro :)
I create login page as you have shown in this video no error working fine the only thing I can not see is data into my database table can you please let me know what I have done wrong??? I rally want to do it ASAP
thanks
Data is not saved in database or you can not connect to database?
I connected I can see the connection but data is not saving in database.
I can see on page but not in database
thanks for the tutorial, can u please give me how to make username unique?
Thanks
can you please do the same tutorial using view models
I do have a question though, how come he didnt do enable-migration since a declaration must be made first and according to my knowledge, using entity framework requires you to do the following first before moving to controllers:
1- enable-migrations
2- add-migration
3- update-database
he didnt do any of that,
does that mean the process of migration can be done automatically by visual studio?
please someone clarify this point for me
enable-migrations is required if you make changes to your model or another model..
Hi thanks for sharing the tutorial. Just one issue. Where can find the database table? The account data should be recorded somewhere, but i cannot find it. Does anybody find this issue?
You can find it in "C:\Users\" location. There would be database .mdf files, for name of the database you can see the web.config.
thanks a lot, I found it.
Excuse me Sir. You created a Dbcontext class object. Dbcontext is of which class.
DbContext class is provided by Entity Framework. We inherit our database context class from DbContext. Our Database context class contains all mapping of tables and relation between them.
@@OpenEducationChannel thanks for your reply
The users have to register himself with the site before using the
functionality. After registrations user id and password will be
provided to the user. Through which he can login. first step ye hai is me kya krna hai kch pta hai
How can it connect database ? I want to database and table with ef code first ...
HI can you please make a tutorial for log in using sql database and how to assign roles?
+ibrahim bossan Ok, i'll make one using MVC and MySql
Assigning roles during registration of a new user
how to solve this error
An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code
How to make User active in the application? After login I use my application, but it's not connected with account I logged in.
sir please make a tutorial on email registration verification using code first..
How can it connect database ? I want to database and table with ef code first ...
please How do I make an mvc login page but connected to the Oracle database, can you set an example
Nice one . but how can i implement this to my own database table ?
+Jigyasu pokhrel You can merge this with your own database simply by adding properties for these classes in your database context class, just like we did at 06:18 in this tutorial. Thanks.
Hi, can you please make tutorial for Custom Login and registration in ASP.NET MVC using Fluent NHibernate or NHibernate? Thanks.
+Stefan Baltov OK, i'll try to make one.
+OpenEducation Thanks
I don't have the Session class in order to store userid and username. What are the alternatives to this? I'm using .net 6
how did u fix?
@@RoshelJudithYou have to choices:
1. Use Identity and it will automatically generate code required for register, login and many more actions.
2. Instead of Session, use Viewbag to pass the data to the view.
How do I access this database in Visual Studio? Say I want to add a new user manually from VS?
you can access it from server explorer in visual studio.
Vary good and easy... But if entered wrong username and password not showing error message
Thanks, Make sure you have added validation summary on the view. Also wrap the login login in try catch and in catch add the same error, because sometimes .single gives error, or instead of .single you can use .where(u => u.Username == user.Username && u.Password == user.Password).FirstOrDefault().
it showing OurDbContext db = new OurDbContext() is an error. what may be the issue
Try to remember that you must always leave a link to the code.
Session["UserId"] Not work in controller class. what is the problem?
I tried this, how come login button doesnt work, login controller had httppost login(User user) and exact code and when clicking login it does nothing? hmm..
Something which you have not tested is what if the password or email are wrong ? this gives an error where you never condition if the password or email are incorrect
which type of database you used to store .
plz explain ....
It's MS SQL localDB.
How do I change the database name to write data? I wrote "public mydbContext() : base("name=mydbtest")" but It doesn't create new db.
The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
I can't get this to work...
Also - "The name 'Session' does not exist in current context"
db.savechanges gives an error, it syas it cant find the function (it can find the definition save changes in ourdbcontext
Tables are created automatically ?
muhammad asad tahir yes, code first approach creates a database if there is no database present.
please about LOGOUT ?
There is need to create one SQL Server connection?
+Thang Nguyen Van No, if you are following this tutorial then there is no need to create SQL Server connection. Entity framework will take care of it automatically and it will create a local database for you behind the scene. You can see that database in your users directory.
+OpenEducation I following this tutorial and I have error below. Please help me!
i.imgur.com/PuD9YPD.png
+Thang Nguyen Van you have to make an object of account class then reassign the data of your account parameter to it. After that you can add. Eg:
UserAccount newUserAccount = new UserAccount();
newUserAccount.Firstname = account.FirstName; ( or what ever your fields are)
db.userAccount.Add(newUserAccount);
Como puedo añadir una vista para eliminar una cuenta? / How can I add a view for delete an account?
Where is the database, so i can store my users there
How can it connect database ? I want to database and table with ef code first ...
its showing error in session how to rectify it
I have created a new page where I'm inserting and getting data from the database.Now getting an error (are you missing a using directive or an assembly reference?) I checked everything but this error is not going.
public DbSet pc_UPC { get; set; }
public DbSet pc_INTERMEDIATE { get; set; }
It's looks like you have not used entity framework reference in the file. Make sure entity framework is imported at the top of this file. If not solved then share you code.
public MotorcraftContext() : base("name=Test_TrainingEntities")
{
}
public DbSet Overpack_I_2_OF_5_BARCODE { get; set; }
public DbSet pc_UPC { get; set; }
public DbSet pc_INTERMEDIATE {get; set; }
I added Context name then it worked but again I'm getting error
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
I am tired now dont know what to do
Megha Misra I knw it's late but if u haven't found d solution and still have tht bug in mind about why it happened ()- have u checked that all ur tables been created or not ? if not than try out migrations and declare ConnectionString inside base() in context file. and then mention it in WebConfig file
can u please tell me how to make username / email unique .?
you can create a method that will confirm this and inside the method all you have to do is run:
bool UserExists = db.userAccounts.Any(x => x.Username == user.username)
It will return a true/false whether the database table userAccounts contains or doesn't contain a row where UserName column contains the username from the model (user.username)
Same procedure is for the E-mail.
or custom attribute for model, ie [IsUnique].. Google for syntax