How to separate username and email on ASP.NET Core Identity - asp.net-mvc-4

I'm so newbie in here as I try to learn this new stuff. But, I have a problem. On asp.net core identity, there's no AccountController (as many blog say it should be modified there), so how can I modify this? I'm so confused with this. Thank you.

The latest version of Identity has a default UI that's included programmatically, via AddDefaultIdentity (which calls AddDefaultUI under the hood). You can use the Identity scaffold to add just the parts you want to modify, which works like an overload: anything not explicitly included in your project falls back to the default UI version.
Right-click on your project in the Solution Explorer, go to "Add" and then "New Scaffolded Item..." On the left of the resulting window, there's a tab for "Identity", which has just one scaffold to choose from, "Identity". Click the "Add" button. This will get you yet another window, where you can now choose which items you want to scaffold into your project.
Be advised that Identity's default UI makes use of Razor Pages, now, so you still won't get an AccountController and such. However, you can simply include pages like Account\Register and Account\Login, which should be the two places you would need to make this change. Feel free to add and modify anything else you like as well.

Related

ASP.NET Core 2.1 Remove Identity Pages created using Scaffolding

I'm probably just missing a simple trick here, but I created the Identity framework in an ASP.NET Core project, created my own fields with my own classes, ran migrations, then once confirmed it was all working with the Default UI. It was working perfectly so went to customize the Identity UI so I could better control specific pages. Trouble was, thought I'd be adventurous and select every page to customize... yes dumb I know.. Now I've got some 80 pages or something that I no longer want.
I really only want to scaffold the registration and manage data pages, if I ran the Scaffolding again will that simply create new pages or fail because the pages already exist, or will it remove any pages that I don't select? I'm loathed to try it for fear of breaking something.
Perhaps it's down to manually deleting the pages I don't want, but will that cause issues with those pages that I haven't selected to customize. Seems great there's a scaffolding option to create the pages, but removing them... it's not so obvious...
For removing unwanted Identity Pages, you could delete them directly from your solution.
For Identity Razor page, if you add scaffold pages or manually create the razor pages with the corresponding name in Identity/Pages/Account, they will replace default Identity Razor page implementation. If there is no razor pages or you delete them, it will reuse default razor page from Razor library.

VS 2017 ASP.NET Core Web Application and Individual User Accounts works but pages are non-existent

When I create a web project using "ASP.NET Core Web Application" / "Web Application" (non-MVC) / "Individual User Accounts"... I get the sample project with Register and Login buttons that show their respective pages when I click on them. HOWEVER... the very weird thing is if I search for "Create a new account" which is on the register page it's not found... and more... there is no AccountController in the Identity area or anywhere... so 1) the pages aren't anywhere in my solution folder and 2) how in the world are these pages showing up?!? I've tried on two different computers now. (using Core 2.1)
As an example this link works:
<a asp-area="Identity" asp-page="/Account/Login">Login</a>
and takes me to:
https://localhost:44300/Identity/Account/Login
and yet my folder structure (both in the solution and on disk) looks like this:
ASP.NET Core 2.1 with Identity automatically includes the "Default UI". It's a Razor Pages class library that's referenced via AddDefaultIdentity in Startup, which under the hood literally calls AddDefaultUI.
If you want the actual files in your project, you need to scaffold them in. Right click your project in the solution explorer and choose Add > New Scaffolded Item... Then, click the Identity listing on the left, and then the Add button. A new window will pop allowing you to select the pages you want included, your context, etc. Configure it how you like and go.
It's also worth noting, that as long as you use AddDefaultIdentity, the default UI is still included, which means you don't actually need all the scaffolded files if you want any of them. They'll essentially function as overrides. Anything specifically included in your project will be used, while anything that's missing will be pulled from the default UI.
This also means that if you want to do something like use standard controller actions and views instead of Razor Pages, the default UI will still be active, and take precedence. You have to use AddIdentity or AddIdentityCore instead of AddDefaultIdentity if you want the default UI off completely.
ASP.NET Core 2.1 introduced Razor UI in class libraries. Identity with it's UI is in nuget package.
The nice thing about this is you can now package UI with your libraries and then expose the UI for overriding.
This post describes how to override the UI. Essentially, you add the pages you want to override to your project to /Areas/Identity/Pages.... the easiest way currently is to run the scaffolder for identity and a visual walkthrough.

Altering the check-in dialogue in ICN (IBM Content Navigator)

In IBM Content Navigator, The "Check In" dialogue contains a Properties Pane, that in turn contains a Class Selector drop down box.
ClassSelector image
I want to keep the check-in functionality, but would like to have that Class Selector box not appear (There is no use case where a user would need to change the document class).
What would be the proper way to achieve this?
Is there a way to extend the ecm/widget/CheckInDialogue.js file AND make the default checkIn action use my new js?
Do I need to create a brand new checkIn action that references a new js?
Do I just change the ICN shipped js/html?
Just to clarify, I do know how to create a plugin, and how to create a js extension to the checkinDialogue.js, and how to remove the classSelector; however I don't know how to make the checkin action use my new script, or the best way to accomplish this.
Thanks!
Before answering your question, I would like to say that I think there is other options to do this without customizing ICN. The two easiest I can see would be:
Use entry templates, that way class selector will be disable on check in by default
Remove the privChangeClass privilege, that should hide the Class Selector (might be difficult if you want to leave full priv.)
Now if you want to hide it without using entry templates or privileges.
Yes, extend the ecm.widget.layout.CommonActionHandler and overwrite the actionCheckIn function and use your CheckInDialog instead of the default one. Then use your CommonActionHandler instead of the default one in your desktop. I don't think there is a way to change the ActionHandler from the admin desktop UI yet (if I missed it please let me know), although it's loaded by the client on the _loadDesktop function and set by the appearance tab but the value is hard-coded, so you might have to inject it after the load of better, call ecm.model.desktop.setActionHander(actionhandler) where actionhandler is the instance, not the class name (string) in a plugin.
You can, this will make things easier to manage if you have several desktops and you want some to use your new Check In dialog and some not.
No, that's a terrible idea :) Future upgrade of ICN and your code will be a nightmare and the delivery process a lot more complex than a simple configuration trick or ICN plug-in, that's what plug-ins are for.
Also a not so clean but really simple solution would be to aspect after the CheckInDialog.prototype on the postCreate function and do a domStyle.set(this.addContentItemPropertiesPane._contentClassSelectorDiv, "display", "none"); to just hide it on all CheckInDialogs.

ASP.NET MVC, razor view, how to modify html on the fly like Glimpse?

I'm upgrading from .NET 2.0 to MVC 4. Back in .NET 2.0 webform, we had to inject license information on the fly to the footer of the software by override the "Render" function in .aspx.cs page (using HtmlTextWriter), find a particular spot of the footer and then insert the license text info there.
The reason I don't want to directly put that in the viewstart page or any razor page themselves using HTMLhelper is because I don't want my customers to mess with it. So hard code is not an option.
I use Glimpse and I see Glimpse is enabled by adding a HTTPModule,etc in web.config and magically, an icon appears on my app. Something similar ?
Bottom line is, I need to hijack the finished HTML output, modify it and return the final result to client.
How do you do this in MVC? HttpModule?
Thanks!
Glimpse uses a feature of ASP.NET called a ResponseFilter to change the output HTML on the fly.
The ResponseFilter, in the case of Glimpse, is set inside the HttpModule - but it could be set anywhere.
Four Guys From Rolla has an old but still relevant article on how to create ResonseFilters.

Creating a new view results in 404 Page

I am trying to do something very simple and I seem to be missing something. I tried to scour the internet for results but haven't gotten anywhere so I was wondering if someone can please advise on this seemingly easy and straightforward task.
I have a working MVC Application and have created Models, Controllers, Views using the defaults (scaffolding).
Now I want to create a new view for one of my controller actions:
public ActionResult Index()
{
return View(db.Blog.ToList());
}
So I right click on Action Result and click Add View.
This gives me a dialog box where I specify a view name of "Test", I click "Create a Strongly Typed View" check box and select model class of Blog.
For scaffold template, I leave empty (note I have tried index without any good result)
Now I click the Add button.
As expected this creates a new view test.cshtml under Views/Blogs
Now when I begin without debugging and go to url: localhost:12341/Blog/Test
I get the following error:
Server Error in '/' Application.
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.
Requested URL: /Blog/test
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
There could be a lot of issues with why it doesn't work. It is probably worth your while to look into ASP.NET MVC routing. For now, Mystere Man's solution might be a "quick fix" assuming you have everything else set up to their defaults.
In particular, when you tell your browser to go to localhost:12341/Blog/Test then it will (probably) look for a Controller called BlogController and then perform the Test action. In your case, your action is called Index so you would want to go to localhost:12341/Blog/Index (though you may be able to omit Index since it's the default action). Lastly, since your action is called Index then the View() function will automatically look for Index.cshtml. This is detailed somewhat in the msdn documentation:
http://msdn.microsoft.com/en-us/library/dd492930(v=vs.100).aspx
In particular:
If the ViewName property is empty, the current action name is used in place of the ViewName property.
Your action method is called Index, not Test. If you want the url to be /Test, then you need to name the action method Test (there are other ways to do it, but this is the best way)
If you want to use the view Test, then you need to specify it in your View() method.
return View("Test", db.Blogs.ToList());
However, you will still need to use the Index url /Blogs/Index because your action method is Index.