I just started some tutorials on MVC (I'm an old .net framework programmer).
In the pre-configured ASP.NET MVC Web App setup (in Visual Studio 2019), I'm trying to find where the actual Login page is (the HTML). I assume this is pre-built into Microsoft Identity. Is there any way to change this login form?
These are scaffolded items Microsoft generated for you for using identity users. You have to follow some steps to add them to your project.
Press the right mouse button on your project.
Press Add
Add a new Scaffolded item
Select the identity options and click add.
Now you can a list of pages. You can select all the pages you want to use in your project. Select the data context dropdown value. The default value will generate an Application db context class for you and install the necessary packages.
Now you can see you have some extra files in your project/Areas/Identity/Pages folder. you will also find a folder named 'data' that implement Applicationdb context.
Related
i want to know asp.net authorize function can it be used in .net core?
Or something can instead in authorize for .net core? thanks
You can use Microsoft.AspNetCore.Identity with Identity Server 4 to authorize your application.
The tutorial from MS is Here.
In short, you can change Authentication to Individual User Accounts when create new projects. Or you can scaffold Identity into an exist project
For example, you can scaffold Identity into an empty project:
From Solution Explorer, right-click on the project > Add > New Scaffolded Item.
From the left pane of the Add New Scaffolded Item dialog, select Identity > Add.
In the Add Identity dialog, select the options you want.
Select your existing layout page, or your layout file will be overwritten with incorrect markup:
~/Pages/Shared/_Layout.cshtml for Razor Pages
~/Views/Shared/_Layout.cshtml for MVC projects
Blazor Server apps created from the Blazor Server template (blazorserver) aren't configured for Razor Pages or MVC by default. Leave the layout page entry blank.
Select the + button to create a new Data context class. Accept the default value or specify a class (for example, MyApplication.Data.ApplicationDbContext).
Select Add.
Then generate Identity database schema:
Install-Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
Add-Migration CreateIdentitySchema
Update-Database
in VS 2019 i have created an web-app like this:
After that i have:
Created a database, and added it in VS2019 "SQL server explorer" (so connection is fine)
Then Scaffolded according to the command in the lasted post here: https://github.com/dotnet/efcore/issues/19986, and i get my "class/model" as a result of this.
Then I add my CRUD pages like demonstrated in this video: https://www.youtube.com/watch?v=q2u1VY28Drs
And that is ok, since the CRUD pages are created (Exists in solution explorer).
Now when i start the app, and manouver to the new CRUD pages as shown i the last video link, it does not work out of the box, the page does not exist: No webpage was found for the web address: https://localhost:44335/V2/index. I dont understand why, but suspect it has something to do with routing.
Or, what could be the problem here?
tnx
Updated 19.10
I create a MCV app, and follow the steps 1&2 above, then i follwo this guide at the "Add model" step: **https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/?view=aspnetcore-3.1 ** and
then add this: using Microsoft.EntityFrameworkCore; in my startup file. I do not add using MvcMovie.Data;
And it still do not work, the documentation is lacking to be mild on the database first approach. What do i NEED to do from the step: "Add a Model" in the MVC guide? anyone?
Or, what could be the problem here?
The key of this issue is that the project in this video is in asp.net core razor page rather than asp.net core mvc.
When you create the project, in Create a new ASP.NET Core web application box ,you should choose the template of Web Application, you can have a look for official documents:
Then you can follow the video operation to create the crud pages.
If it is in the asp.net core mvc project, you need to create New scaffolded Item in the Controller folder and should select MVC Controller with views, using Entity Framework template, you can have a look for this.
I am new to .NET Core and wanted to ask about Identity.
I bought a book and followed all the instruction. It is very simple to set Identity the way the book describes.
Create an Account Controller, LogIn, Logout views etc...
But when I create a new project with Visual Studio with Individual User Accounts selected.
I can't find the Account Controller folder. There is an Areas folder but almost empty. Areas\Idnetity\Pages\_ViewStart.html.
I checked hidden files etc, but couldn't find Account or Identity Folder.
The login link is like this
https://localhost:44313/Identity/Account/Login
Identity is working but where are the codes?
As this entry states:
In ASP.NET Core 2.1 we can now ship Razor UI in reusable class
libraries. We are using this feature to provide the entire identity UI
as a prebuilt package (Microsoft.AspNetCore.Identity.UI) that you can
simply reference from an application.
Notice that you are asking this feature to be effective by adding .AddDefaultUI(UIFramework.Bootstrap4) to ConfigureServices method.
If you still love to scaffold the Identity as old days, use this cli command:
dotnet aspnet-codegenerator identity --useDefaultUI
For more information on scaffolding options visit here.
I have an ASP.NET application which works just fine, but which is becoming unwieldy. I would like to incorporate MVC3 functionality in it for any new pages, and gradually convert all the old pages. I plan to use the Razor syntax.
I've got it working. I can serve up pages just fine. It was a bit of a battle, but things looked good. I believe I have all the directory structure and the referenced DLLs.
My only real problems are with the IDE:
I cannot select "Add Controller.." when I right-click on the Controllers folder. Ditto for Views, and "Add Area..." from the project right-click menu.
I cannot add template items related to MVC3 (or MVC2, which I also have installed).
I also cannot validate HTML5 (all tags are invalid), but I think this is a separate issue, because this functionality doesn't work on my MVC3 projects either.
I would not even know that these things were missing if it didn't work perfectly for a project created as an MVC3 project (with Razor syntax), so it must be something specific in the solution or the project, but I cannot find it anywhere.
My question:
Where do I change this so that the IDE acknowledges it as an MVC project?
The reason why the menus are not coming is visual studio IDE do not consider this as a real ASP.NET MVC project because the project file does not say so. So we should update the project file to include the project type guid for ASP.NET MVC and then the IDE willl start supporting the menus specific for ASP.NET MVC type project.
Step 1
Go to your solution explorer and unload the existing ASP.NET project by right clicking and selecting “Unload Project”
Step 2
Right Click the Project in solution explorer and select “Edit your project file name“
Step 3
Add the below entry to it inside the ProjectTypeGuids section
{E53F8FEA-EAE0-44A6-8774-FFD645390401};
Save. Reload the Project and you will be good now.
I clearly explained it here in a blog post.
There are many posts on this, most of which suggest adding the MVC project type GUID to the .*proj file.
THe website project model doesn't have a project file though, so is there some way to get support for the add view dialog and tooling with a hybrid website / MVC project?
There is no way to achieve what you want in a WebSite (at least not currently). The Add Controller functionality is implemented as a VSPackage that gets loaded when the MVC project type GUID is detected (that's why all the other posts mention it).