The project that visual studio 2019 creates for an ASP.NET Web Application (.NET Framework) MVC5 comes with Bootstrap 3.x and many other outdated components. Not to mention unneeded things like modernizr.
If you update Bootstrap, you know need to modify the ScriptBundle in BundleConfig to get the application to start, and then modify the CSS to get the premade web pages to render properly.
Also, the folder structure is not the best.
Is there a project template out there that has all essential components updated, and a clean-up NuGet and folder structure?
I tried using Rider but they do not have a built-in template.
I went t the .Net Foundation GitHub and did not find any: https://github.com/dotnet?q=.NET+framework&type=&language=c%23&sort=
I also search GitHubub and did not see any: https://github.com/search?q=ASP.NET+Web+Application+%28.NET+Framework%29+project+template
I am looking for a project template that has the basic structure to create a Clean Architecture in .NET Framework and not .NET Core
I know it's legacy, but unfortunately, I need it for a university class (University courses take a while to get updated, and in this case, they claim that there are sufficient companies out there using ASP.NET MVC 5 to Merrit them teaching it) But yes, No one should be using this to start a new project they intend to put into a real-life production scenario.
Thank you
Related
We have MVC ASP.NET Web Applications written within the ASP.NET 4.* scope that we would like to phase across to ASP.NET 5. While we transition (as well as client-side JavaScript scripts/libraries, CSS, etc) we'd like the old app (which obviously contains Views, Controllers, Helpers, Utilities, Attributes, etc) to co-exist in an MVC/Web-Application ASP.NET 5 project, with the new (ASP.NET 5) codebase.
Firstly is this possible with minimal changes ? I have been doing some testing and a lot of reading - for the client-side libraries I should be able to handle the co-existence by copying the existing content into the wwwroot area via Gulp. My question is mostly around the server-side artifacts - for example I am using a framework (as specified in project.json) of "dnx46" (which seems to be the most appropriate for this purpose), but I am getting a number of conflicts (around missing assemblies) around simple things like Project references, ActionFilterAttribute & AuthorizeAttribute [eg. The type or namespace name 'AuthorizeAttribute' does not exist in the namespace 'System.Web.Mvc' (are you missing an assembly reference?)] (because they no longer exist in the System.Web.Mvc namespace), HttpContextBase, security (OWIN, etc) etc - note that I'm aware of including References which are reflected within the project.json file (and some that finish up inside the appropriate 'wrap' folder location)
If there is a preferred approach - some possibilities are
create a new WebApplication ASP.NET 5 project which among other things contains out of the box Bower, npm, Gulp, CodeFirst Migrations, Controller/Views, etc ready to go then copy your legacy project artefacts in
create a blank ASP.NET 5 project and start everything from the ground up (as per http://aspnetmvc.readthedocs.org/projects/mvc/en/latest/migration/migratingfrommvc5.html) then again copy your legacy project artefacts in
create a new WebApplication ASP.NET 5 project, then with a post-build event copy your new and legacy artifacts into a third vanilla project. In this way the old and new projects live in isolation and only get merged in at deployment time
separate concerns like Helpers, Utilities, Attributes, etc that are used within the UI project into a traditional Class Library project and only keep the bare minimum (Views, Controller, scripts, css, etc) within the UI (ASP.NET 5) project
Any ideas would be greatly appreciated.
I don't know that how your MVC 4 project is structured, I would prefer to create it from scratch using Blank ASP.NET 5 Template targeting dnx451. The thing I don't understand is previous .NET stuff like Authorize attribute are not found as they are available and I'm using it. Here are some stuff that might be help to you while migrating:-
Your EF Context and security classes should be considered as middlewares in ASP.NET 5 and should be configured in Startup.cs class which is not found in MVC 4.
Put all your CSS\JS files in wwwroot and make a reference _Layout.cshtml as root as normally (use gulp task runner for better performance.)
Must target dnx451, because dnx50 does not contain all of the libraries and it is about immensely in ASP.NET Core RC2 and RTM. (If you can't wait for RC 2).
If you're using Identity for Authorization, note that there is now a big change in Authorization Policy as can be found Here
It is a little bit difficult but it will optimize your team working and will make your project flow faster than before.
I've been exploring the Azure Active Directory services and was pleased with how easy it was to hook up an arbitrary ASP.NET MVC website to it. I've experimented with this in Visual Studio 2012 and all works well. Especially using the Identity and Access Tool extension for VS2012.
Now here comes the tricky part: This tool is however deprecated and not supported on, nor available for Visual Studio 2013.
There are several MSDN documents on the matter, like this excellent tutorial, only I find them all targeting VS2012 and the forementioned tool. For new projects the process is "simplified when creating a new web application". But I don't want a new application - I want to hook up existing applications in VS2013.
Now the question is: is there a 'decent' way to integrate Azure ActiveDirectory, especially the Single Sign-On feature, to an existing ASP.NET MVC 5 web application in Visual Studio 2013?
At least with the same ease as the I&A Tool, but without the need to recreate or migrate my entire application, of course.
Depending on the complexity of your project, you can either create a new project and import your project files to the new project or import the identity settings to your existing project.
Since the identity controls are really just a set of files and configuration, you should be able to create a project with the identity settings you want and then copy over the files / configuration to your existing project. You may also need to add references to things like Microsoft.AspNet.Identity.Owin and any security providers you need. Files to take a look at include:
App_Start/IdentityConfig.cs
App_Start/Startup.Auth.cs
Controllers/AccountController.cs
Startup.cs
Web.config
Yes, it's a pain, and hopefully there will be an easier way of adding or changing identity later, but this is the best I've come up with for now.
I'm using Visual Studio 2012 and have just installed "Microsoft ASP.NET and Web Frameworks 2013.1 - Visual Studio".
As expected, it added the option to create an "ASP.NET MVC 5 Empty Project". The thing is, I see no way of jump-starting an already functional "base application" as I had when I was using MVC 4 (e.g. "Asp.NET MVC 4 Web Application"). I only see an empty template.
I've seen answers such as:
How can I add the MVC 5 project template to VS 2012?
Create and Run MVC 5 Project in VS 2012
Direct download link to ASP.NET MVC 5 for VS 2012
And found this article on the matter.
This is obviously not a show-stopper as I can always create the application from a scratch, but I still would like to know if it is possible to achieve that on VS 2012. Did I miss a step, or do I need VS 2013 for that? A fully functional Web application template (with authentication etc.) would be nice to dabble around MVC 5's new features or for prototyping.
After creating a new project using ASP.NET MVC 5 Empty Project, you can right click on the project, then click Add.. > New Scaffolded Item..., select MVC on the left, then MVC 5 Dependencies and choose Full dependencies from the prompt.
This will add a default layout (Views\Shared\_Layout.cshtml), Content folder, Scripts folder with bootstrap, jquery, modernizr, etc, and other things the Web Application template creates.
If you get the error "CS0103: The name 'Styles' does not exist in the current context" just add <add namespace="System.Web.Optimization"/> under <namespaces> in Views/web.config
The answer from Sean Lynch is nice but not really complete.
However there is this nice guy that took the time to prepare the template just like in Visual Studio 2013. You will get everything down to the bootstrap template and pre-configured database table for authentication.
All you need to do is change the DefaultConnection in Web.Config to you SQL Server and voila all the relevant authentication table will be created for you.
Archive of the original blog (by web.archive.org)
Update
The original blog is no longer online, but thankfully his template is still online. You can download the MVC5 Template for Visual Studio 2012 Here:
Direct link to MVC5 Template For Visual Studio 2012
And here is the excerpt from the original blog:
Installing the template is very simple, there are just two steps:
Copy it into the following folder of your computer (creating the directory structure if necessary):
%USERPROFILE%\Documents\Visual Studio 2012\Templates\ProjectTemplates\Visual C#\Web
Once you’ve done this, simply restart Visual Studio and you will have this template available in the dialog box to create a new project under “Visual C# > Web”.
Now you can create applications with a little more shape than the mere empty structure provided by default and enjoy the benefits of adopting Bootstrap and its responsive design, a full membership system and user authentication, bundles, filters, some content pages, etc.
You have 2 option to fix it.
Install the latest 2013 version which have MVC5 support inbuilt (VS2013 missing MVC3 and ASPX file template (ASPX templates will be added in future))
stay with 2012 update 4. Read my old article to get it fixed http://geekswithblogs.net/anirugu/archive/2013/11/28/mvc-5-in-visual-studio-2012-update-4.-how-to.aspx
I'm not using 2012 now, but rather 2013, and I see the mvc 5 template there. However, I did this a while back before I had any mvc 5 templates showing up by installing mvc 5 first. You should be able to download from http://www.asp.net/mvc/mvc5.
Also make sure your target framework is set correctly.
Then I updated the web config like this:
You have to have the correct versions of the assemblies. I googled a lot to get this info, so it should still be available if you do some research.
I know Twitter bootstrap has several templates rolled with mvc 4 when creating a new project, but does one using Semantic UI exist? Google searches returns little of relevance to me, neither am I able to find any when searching amongst the online templates in VS2012.
No, it doesn't exist out-of-box, but you are free to create your own template. The templates for MVC in both 5 (VS 2013) and 6 (VS 2015 preview) are also using Bootstrap.
Alternatively, you can add the NuGet package to your project (though, it does not seem to be an official project package):
PM> Install-Package SemanticUI.ASP.NET.MVC
We are in the middle of development for a core ASP.NET MVC web project and a customer plugin in the form of an MvcContrib plugin web project -- a web project injected into the core web as an area. The plugin is a soft reference in the core project, so it can be developed completely separately and dropped in.
I am trying to generate a way to debug/code the plugin, so that the multiple custom plugins can be developed independent of the core web.
The developers should only have to worry about coding and testing the plugin code. Also, I don't want them to change the core code in this custom plugin project -- that should be done in the core anyway.
I created the core web as a NuGet package and included all the necessary files so I could include it in a web.
My thinking was that I could create an empty web, install my core web, and the developers could have an F5-driven debugging environment.
I tested by creating a blank Mvc project, installed my core package and included one of my plugins. I changed the namespace of this empty web app to the namespace of the core web, thinking that Visual Studio debugging would properly attach and my core assembly.
Simple VS debugging in the empty app does not work -- I receive an HTTP Exception, most likely due to my routes not being registered. I also see that my log4net is not creating its logs folder, so I know the assembly's app start is not being called.
So I see that VS is not attaching to and calling my core assembly.
Can I use this empty web as a host project for my nuget installed web and debug? If so, what configuration am I missing?
If not, how can I include the core web in each customer plugin project in such a way that I can drop my DLL into the bin and debug it?
Using:
Visual Studio 2010
ASP.NET MVC2
The way we are doing things that works pretty well is to use a combination of Web Activator and Razor Generator (available as a Visual Studio extension). In order to access the views within the core web application, the consuming client application needs to know about them, either because they are all included as file references inside the Nuget package (messy) or because they are compiled into the core web dll. You can do that using Razor Generator. Once installed via Nuget you would need to change the Custom Tool property for each .cshtml file to RazorGenerator, which will create a .generated.cs file for each view. This will allow your sample client to use the layout and views from the core web application.
David Ebbo has some useful blog posts on Razor Generator
Couple that with Web Activator to create a PostActivationStartMethod that runs your initialisation code (such as initialising Log4Net) and you should be good to go. We've had this running in 2 scenarios - consuming the framework package via Nuget and adding a project reference directly. Debugging was not working for the Nuget package consuming route but we don't include the pdb files in the Nuget package. We can debug when adding a project reference directly though.