ASP.NET Core Boilerplate

ASP.NET Core-Boilerplate

ASP.NET Core Boilerplate is a professional ASP.NET MVC template for building secure, fast, robust and adaptable web applications or sites. It provides the minimum amount of code required on top of the default MVC template provided by Microsoft.

New Project

The main benefits of using this template are:

  • Security
  • Performance
  • Search Engine Optimization (SEO)
  • Accessibility
  • Browser Compatibility
  • Resilience and Error Handling
  • Easier Debugging and Performance Testing Tools
  • Patterns and Practices
  • Atom Feed
  • Search
  • Social Media Support

ASP.NET 4.6 MVC 5 and ASP.NET Core Support

Two templates are provided. One for ASP.NET 4.6 MVC 5 and another ASP.NET Core template which is currently under development and is missing some features due to ASP.NET Core still being in Beta. For more information about what's new in the ASP.NET Core template, see here.

MVC 5 Technology Map

ASP.NET Core Boilerplate Technology Map]

ASP.NET Core Technology Map

ASP.NET Core Technology Map

Why Do I Need It?

The default MVC template that Visual Studio gives you does not make best use of the tools available. It's insecure, slow, and really has a very basic feature list (That's the point of it). ASP.NET Core Boilerplate provides you with a few more pieces of the puzzle to get you started quicker. It makes liberal use of comments and even gives you a check-list of tasks which you need to perform to make it even better.

The rest of this article is going to briefly go through the improvements made over using the default MVC template. I'll then finish up with instructions on how you can use it. Also, look out for more posts in the future, where I will go through each feature in detail.

Secure By Default

The default MVC template is not as secure as it could be. There are various settings (Mostly in the web.config file) which are insecure by default. For example, it leaks information about which version of IIS you are using and allows external scripts to access cookies by default!

ASP.NET Core Boilerplate makes everything secure by default but goes further and uses various HTTP headers which are sent to the browser to restrict things further.

It also makes use of the new Content Security Policy (CSP) HTTP Header using the NWebSec NuGet packages. CSP revolutionizes web security and I highly recommend reading the above link.

Setting up SSL/TLS, so that your site runs over HTTPS is made easy with easy step by step instructions and links.

Fast By Default

The default MVC template does a pretty poor job in the performance department. Probably because they don't make any assumptions about which web server you are using. Most of the world and dog that are writing ASP.NET MVC sites use IIS and there are settings in the web.config file under the system.webServer section which can make a big difference when it comes to performance.

ASP.NET Core Boilerplate makes no such assumptions. It turns on GZip compression for static and dynamic files being sent to the browsers making them smaller and quicker to download. It also uses Content Delivery Networks (CDN) by default to make common scripts like jQuery quicker to download (You can turn this off of course but the point is ASP.NET Core Boilerplate is fast by default).

That's not all! There are a bunch of other tweaks and examples of practices which can help improve the performance of the site. ASP.NET Core Boilerplate achieves a score of 96/100 on YSlow (Its not possible to get the full 100 as some of it's criteria contradict each other and site scripts need to be moved to a CDN).

Search Engine Optimization (SEO)

The default ASP.NET MVC template takes no consideration of Search Engine Optimization at all. ASP.NET Core Boilerplate adds a dynamically generated robots.txt file to tell search engines which pages they can index. It also adds a dynamically generated sitemap.xml file where you can help search engines even further by giving them links to all your pages.

ASP.NET MVC has some very useful settings for appending trailing slashes to URL's and making all URL's lower case. Unfortunately, both of these are turned off by default, which is terrible for SEO. This project turns them on by default.

It also includes an MVC filter which helps to redirect non-canonical URL's (URL's without a trailing slash or mixed case characters which are considered different URL's by search engines) to their canonical equivalent.

Accessibility

4% of the world population is estimated to be visually impaired, while 0.55% are blind. Get more statistics here. ASP.NET Core Boilerplate ensures that your site is accessible by adding aria attributes to your HTML mark-up and special short-cuts for people using screen readers.

Browser Compatibility

Websites need to reach as many people as possible and look good on a range of different devices. ASP.NET Core Boilerplate supports browsers as old as IE8 (IE8 still has around 4% market share and is mostly used by corporations too lazy to port their old websites to newer browsers).

ASP.NET Core Boilerplate also supports devices other than desktop browsers as much as possible. It has default icons and splash screens for Windows 8, Android, Apple Devices and a few other device specific settings included by default.

Resilience and Error Handling

At some point your site is probably going to throw an exception and you will need to handle and log that exception to be able to understand and fix it. ASP.NET Core Boilerplate includes Elmah, the popular error logging addin. It's all preconfigured and ready to use.

ASP.NET Core Boilerplate uses popular Content Delivery Networks (CDN) from Google and Microsoft but what happens in the unlikely event that these go down? Well, ASP.NET Core Boilerplate provides backups for these.

Not only that but standard error pages such as 500 Internal Server Error, 404 Not Found and many others are built in to the template. ASP.NET Core Boilerplate even includes IIS configuration to protect you from Denial-of-Service (DoS) attacks.

Easier Debugging and Performance Testing Tools

ASP.NET Core Boilerplate makes use of Glimpse (As advertised by Scott Hanselman). It's a great tool to use as you are developing, to find performance problems and bugs. Of course, Glimpse is all preconfigured, so you don't need to lift a finger to install it.

Patterns and Practices

Doing things right does sometimes take a little extra time. Using the Inversion of Control (IOC) pattern for example should be a default. ASP.NET Core Boilerplate uses the Autofac IOC container by default. Some people get a bit tribal when talking about IOC containers but to be honest, they all work great. I picked Autofac because it has lots of helpers for ASP.NET MVC and Microsoft even uses it for Azure Mobile Services.

ASP.NET Core Boilerplate also makes use of the popular LESS files for making life easier with CSS. For an example, it can make overriding colours and fonts in the default Bootstrap CSS a cinch.

ASP.NET MVC is a complicated beast. You can end up with lots of magic strings which can be a nightmare when renaming something. There are many ways of eliminating these magic strings but most trade maintainability for slower performance. ASP.NET Core Boilerplate makes extensive use of constants which are a trade-off between maintainability and performance, giving you the best of both worlds.

Atom Feed

An Atom 1.0 has been included by default. Atom was chosen over RSS because it is the better and newer specification. PubSubHubbub 0.4 support has also been built in, allowing you to push feed updates to subscribers.

There is a lot more to implementing search in your application than it sounds. ASP.NET Core Boilerplate includes a search feature by default but leaves it open for you to choose how you want to implement it. It also implements Open Search XML right out of the box. Read Scott Hanselman talk about this feature here.

Social Media Support

Open Graph meta tags and Twitter Card meta tags are included by default. Not only that but ASP.NET Core Boilerplate includes fully documented HTML helpers that allow you to easily generate Open Graph object or Twitter Card meta tags easily and correctly.

How can I get it?

That's easy, just choose one of the following options:

  1. Get the Visual Studio 2013 extension here and in Visual Studio go to File -> New Project -> Web.
  2. Clone the git repository:

    git clone https://github.com/Dotnet-Boxed/Templates
    

Release Notes and To-Do List

You can find release notes for each version here and a To-Do list of new features and enhancements coming soon here.

Bugs and Issues

Please report any bugs or issues on the GitHub issues page here.

Future of the project

At some point, I will try to create a Visual Studio Deployment package (VSIX) and list this project template on the Visual Studio extensions site. To use the template, it will be as easy as choosing ASP.NET Core Boilerplate from the online templates in the File -> New Project -> Online Template menu. Unbelievably, it's actually pretty complicated to create one of these. I found the Export Template Wizard Visual Studio extension which can do this easily but it's not been updated since Visual Studio 2010.

I am also taking a look at creating separate Visual Studio templates which include ASP.NET Web API and OAuth authentication. This is of course an open source project, I fully expect contributions and suggestions from the community.

Web Mentions

What's this?

0 Replies

GitHub Comments

RehanSaeed

Bruno Feliciano Bruno Feliciano commented on 2015-03-16 12:55:55

Hi,

Could you please post a change log, when you update the template?

Tks!

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-03-16 14:37:10

Hi,

Could you please post a change log, when you update the template?

Tks!

Hi Bruno, I already do, you can find it here.

RehanSaeed

hossein hossein commented on 2015-04-07 04:58:42

hi, thanks for your job. I used it and it was very nice and helped me. but I had some problems such as packages reinstall and configuring IIS. if you could add some other options like membership and account pages it will be much better.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-04-07 06:06:42

hi, thanks for your job. I used it and it was very nice and helped me. but I had some problems such as packages reinstall and configuring IIS. if you could add some other options like membership and account pages it will be much better.

Hi,
Its on the list. there are still several other improvements to do before I add Identity which is a feature not everyone wants. I have to add a way to select the type of identity provider like Visual Studio does by showing a special UI.

RehanSaeed

Vijay Vijay commented on 2015-04-21 20:22:41

This rocks!

  1. Does the template auto configure Nwebsec, can you list what are the configurations on settings.
  2. Can you expand on how to IOC and Open Search please
  3. Also which membership provider do you recommend, do you plan to include one into this VSIX, with a web UI for admin management
RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-04-21 20:43:59

This rocks!

  1. Does the template auto configure Nwebsec, can you list what are the configurations on settings.
  2. Can you expand on how to IOC and Open Search please
  3. Also which membership provider do you recommend, do you plan to include one into this VSIX, with a web UI for admin management

Thanks Vijay,

  1. It configures NWebSec as much as it can. Of course, you will need to customize it to your own requirements. You can see my post on Content Security Policy for more information.
  2. I am planning more blog posts. I will make sure to add IoC and Open Search to the list. You can check the ReadMe.html for a link to Scott Hanselman's blog covering open Search.
  3. You can add the ASP.NET Identity NuGet package yourself or use Windows Authentication depending on what you need. I have not included this but I do plan to look into its feasibility. I may be able to hook into Visual Studio's Authentication dialog which is displayed for normal web projects but I'm not sure how to do this yet.

Things you can look forward to this week, is added Atom/RSS feed support and a much improved ReadMe.html with tonnes of new information and you can check things you have completed off the list. I hope that helps.

RehanSaeed

Abrian Stemmet Abrian Stemmet commented on 2015-05-05 10:37:40

Hi there!

Thanks for the great work! One question:
When receiving updates how do I implement these changes to my project? Can it automatically make the changes from each update?

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-05-05 12:47:06

Hi there!

Thanks for the great work! One question:
When receiving updates how do I implement these changes to my project? Can it automatically make the changes from each update?

Thanks, I really appreciate all feedback.

I'm afraid that would not be possible. If I create some kind of code updater application, it would be very difficult to deal with edits or deletions that developers have made.

Instead, I have added a note to ReadMe.html to point developers to the GitHub changes page where they can manually see what the changes are and make fixes themselves.

This project is still fairly new. Hopefully it will settle down soon with less changes. I'm certainly running low on ideas

RehanSaeed

Sundeep Sundeep commented on 2015-05-11 15:34:54

You saved me lot of time ! Keep rocking !

One quick question:

I'm trying to configure windows authentication using this template. I did the following steps

  1. Included following section in web.config under system.web
authentication mode="Windows" 
 authorization
   deny users="?" 
authorization
  1. Changed the project properties - Anonymous Authentication -> Disabled and Windows Authentication -> Enabled

  2. I use IIS Express and when I run - It gives a login prompt which doesn't happen on Microsoft's default template.

I tried tweaking couple of settings in web.config but in vain. Can you please help ?

RehanSaeed

Abrian Stemmet Abrian Stemmet commented on 2015-05-12 09:06:06

Rehan, what are your thoughts on implementing user access control to the boilerplate? Would you make use of the identity framework?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-05-12 18:12:04

Rehan, what are your thoughts on implementing user access control to the boilerplate? Would you make use of the identity framework?

I've been asked this several times. I really must add this information to the ReadMe file. I recommend using the ASP.NET Identity. Please don't roll your own unless you are a security expert, you will most likely get it wrong as it's a ridiculously complicated subject that even experts get wrong.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-05-12 18:15:21

You saved me lot of time ! Keep rocking !

One quick question:

I'm trying to configure windows authentication using this template. I did the following steps

  1. Included following section in web.config under system.web
authentication mode="Windows" 
 authorization
   deny users="?" 
authorization
  1. Changed the project properties - Anonymous Authentication -> Disabled and Windows Authentication -> Enabled

  2. I use IIS Express and when I run - It gives a login prompt which doesn't happen on Microsoft's default template.

I tried tweaking couple of settings in web.config but in vain. Can you please help ?

I do intend to add a section on authentication in the ReadMe file, outlining how to do Windows or OAuth authentication. I may even create new project templates with these included out of the box but I want to finish up a few features first and MVC 6 is coming out too so there is a lot to do. It looks like you have done everything right. My advice would be to create a new Web Project with Windows authentication and see what is added to the project.

RehanSaeed

Chandra Chandra commented on 2015-05-15 01:40:57

hi Rehan,

I really like this template and feature you have added.
While i am changing the theme by replacing the respective bootstrap file it is not working as i expected.

Do we need to do anything different to change the theme of this project ?

Regards,
Chandra

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-05-15 06:13:56

hi Rehan,

I really like this template and feature you have added.
While i am changing the theme by replacing the respective bootstrap file it is not working as i expected.

Do we need to do anything different to change the theme of this project ?

Regards,
Chandra

You can change the theme a few different ways. The first is to edit the bootstrap site.less file to override the bootstrap settings and customize it. Some themes come as bootstrap-theme's which can be placed after the bootstrap files but most themes totally replace the bootstrap less or css files. So it depends on what theme you are using.

RehanSaeed

Biapar Biapar commented on 2015-05-21 07:14:42

Could you integrate ASP.NET identity out if the box?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-05-21 13:01:51

Could you integrate ASP.NET identity out if the box?

Its coming after the MVC 6 template. I have talked to Microsoft devs about hooking into the VS authentication selection dialog. If they allow that, then I don't need to create a special project template including identity support.

RehanSaeed

girish girish commented on 2015-05-26 12:35:06

how to add asp.net boilerplate template to visual studio

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-05-26 17:18:32

how to add asp.net boilerplate template to visual studio

There are three ways:

  1. Download and install it from the visual studio gallery.
  2. Go to File -> New Project in visual studio and search for it in the online section at the bottom left.
  3. Go to Options -> Tools and Extensions and search for it.
RehanSaeed

Mark Mark commented on 2015-06-24 14:21:48

I think it's a great project, but lacks authentication

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-06-24 14:30:46

I think it's a great project, but lacks authentication

Thank you for your comment. I agree with you and will add it in future. Right now, I'm focusing on the MVC 6 Boilerplate project and some more improvements to MVC 5. For now, there is a section in the ReadMe.html file which covers authentication and how it can be handled.

RehanSaeed

Geirr Winnem Geirr Winnem commented on 2015-06-27 11:22:06

The dynamicIpSecurity section in web.config causes IIS below 8.0 to return a HTTP Error 500.19 - Internal Server Error
with the lovely details:
Config Source
-1:
0:
Which must be one of the most meaningless error messages microsoft ever produced.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-06-29 08:48:15

The dynamicIpSecurity section in web.config causes IIS below 8.0 to return a HTTP Error 500.19 - Internal Server Error
with the lovely details:
Config Source
-1:
0:
Which must be one of the most meaningless error messages microsoft ever produced.

Thanks for that. I'll see if I can put a note on the ReadMe file about it.

RehanSaeed
(edited )

Richard B Richard B commented on 2015-06-30 11:10:12

Small issue/edge case I had with the SEO option setting LowercaseUrls = true, this appears to break the Kendo grid clienttemplate as it lowercases the Id column.

So;

Html.Kendo().Grid(Model)
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.Id).ClientTemplate(@Html.ActionLink(" ", "Details", "RolesAdmin", new { Id = "#=Id#" },
                   new { @class = "viewIcon", @title = "Details" }).ToHtmlString())
                   .Width(25).Title(" ").Filterable(false).Groupable(false);

for example no longer works. Error is thrown in page "id not defined..." Removing the optimization fixed my issue.

RehanSaeed

Richard B Richard B commented on 2015-06-30 11:18:27

If you are going to roll in Identity membership, you might want to consider rolling in Brock Allen's IdentityServer and IdentityManager. Does all the things ASP.Net Identity does currently, does them better and with increased security, and more. It's pretty awesome.

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-06-30 12:44:32

Small issue/edge case I had with the SEO option setting LowercaseUrls = true, this appears to break the Kendo grid clienttemplate as it lowercases the Id column.

So;

Html.Kendo().Grid(Model)
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.Id).ClientTemplate(@Html.ActionLink(" ", "Details", "RolesAdmin", new { Id = "#=Id#" },
                   new { @class = "viewIcon", @title = "Details" }).ToHtmlString())
                   .Width(25).Title(" ").Filterable(false).Groupable(false);

for example no longer works. Error is thrown in page "id not defined..." Removing the optimization fixed my issue.

I have some experience using Kendo. This is an interesting problem, Kendo is probably adding upper-case characters instead of lower-case in the URL and I don't remember seeing an option to be able to force lower-case. You should consider the canonical meta tag instead then in _Layout.cshtml.

<link rel="canonical" href="">
RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-06-30 12:50:32

If you are going to roll in Identity membership, you might want to consider rolling in Brock Allen's IdentityServer and IdentityManager. Does all the things ASP.Net Identity does currently, does them better and with increased security, and more. It's pretty awesome.

Thanks for that Richard. I'd heard of that project but not used it. I'll certainly look into it when I get to that stage. Dominick Baier (Also from ThinkTecture) trained me in WCF and I know their stuff will be good :).

Right now I'm still working on the MVC 6 project which is 60% completed, the NuGet package v1 is out already. Now I just need to get the project template finished and pushed out. There are still lots missing in MVC 6 so it's not as whole as I'd want but it's the best I can do at the moment.

RehanSaeed

Jose Quinones Jose Quinones commented on 2015-06-30 14:29:28

I'm in the middle of a few projects right now that are not MVC but want to ask before I forget. I'm a Unity IoC user, will it be easy to swap out IoC containers and can you foresee any issues using Unity instead of autofac?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-06-30 15:01:40

I'm in the middle of a few projects right now that are not MVC but want to ask before I forget. I'm a Unity IoC user, will it be easy to swap out IoC containers and can you foresee any issues using Unity instead of autofac?

I used to use Unity too but switched after having to use Azure Mobile Services where Microsoft ships Autofac by default. I now prefer it to Unity but all IoC containers are good these days and I realize it's about personal preference.

The Autofac code below is magical, it registers several MVC types including UrlHelper, HttpContext etc. As long as you can find a replacement for this in Unity I see no problems and the only code you need to change is in Startup.Container.cs.

builder.RegisterModule<AutofacWebTypesModule>()

I've added a comment to Startup.Container.cs in the template explaining this.

RehanSaeed

Reza Rad Reza Rad commented on 2015-07-03 00:57:20

hi Rehan,

thanks for great template.
how can change direction template of ltr to rtl ?

RehanSaeed

Milicent Milicent commented on 2015-07-07 21:58:40

Hello! I am doing research for my Capstone project, the last piece of the puzzle necessary to graduate from college with an AAS in Computer Science. My question is, should I use MVC Boilerplate to build my project website or should I stick with ASP.NET MVC? I ask because I still heavily utilize tutorials and documentation to complete projects. I want to use best practices and challenge myself, but also do not want to get in over my head. Thank you for the feedback!

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-07 23:07:07

hi Rehan,

thanks for great template.
how can change direction template of ltr to rtl ?

I haven't researched internationalization too deeply yet but it's a subject I'll add to my TODO list. Using RTL specifically is something that HTML provides and nothing to do with ASP.NET MVC but there are other features like date formatting, number formatting and language support which MVC can help with.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-07 23:11:05

Hello! I am doing research for my Capstone project, the last piece of the puzzle necessary to graduate from college with an AAS in Computer Science. My question is, should I use MVC Boilerplate to build my project website or should I stick with ASP.NET MVC? I ask because I still heavily utilize tutorials and documentation to complete projects. I want to use best practices and challenge myself, but also do not want to get in over my head. Thank you for the feedback!

Interesting question. ASP.NET Core Boilerplate certainly has you covered with best practices, security, performance etc.

However, I hesitate to recommend it because you say you are very new to MVC. Introducing too many new concepts may overwhelm you and there certainly is a lot to learn.

There are a few things that may trip you up if you don't have enough knowledge. I'll leave you to judge if you have learned MVC thoroughly enough.

RehanSaeed

Founder Founder commented on 2015-07-10 06:58:35

I tried to download this through Visual Studio, but it seems to have disappeared from the online templates.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-10 09:17:41

I tried to download this through Visual Studio, but it seems to have disappeared from the online templates.

It seems ok at the moment. If you still can't find it get it from the Visual Studio Gallery here.

RehanSaeed

Tony Tony commented on 2015-07-10 10:58:28

Hi, I am trying to use your template with some MVC Grid library and hit some problems:

  1. First I tried Grid.Mvc, I can't get the paging, sorting & filtering to work, even after I enabled Cross-Origin Request.
  2. Then I tried NonFactors.Grid.Mvc5, same problem, paging, sorting & filtering don't work.

There is no error in web or back-end, the page just reloaded and same data was displayed again.
I am using VS2003 & VS2005 RC (ASP.Net MVC5 project)

Have anyone been facing the same problem?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-10 11:09:07

Hi, I am trying to use your template with some MVC Grid library and hit some problems:

  1. First I tried Grid.Mvc, I can't get the paging, sorting & filtering to work, even after I enabled Cross-Origin Request.
  2. Then I tried NonFactors.Grid.Mvc5, same problem, paging, sorting & filtering don't work.

There is no error in web or back-end, the page just reloaded and same data was displayed again.
I am using VS2003 & VS2005 RC (ASP.Net MVC5 project)

Have anyone been facing the same problem?

NOTICE TO ALL: Please raise any issues on the GitHub issues page.

Do you get any errors in your browser console or Elmah? If so, adjust your Content Security Policy (CSP) policy. The grid may use inline scripts for example.

RehanSaeed

Duncan Duncan commented on 2015-07-10 11:28:34

hello, when i make changes, to the website, the changes are only seen in internet explorer, how do i make the changes visible to other browsers?

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-10 12:18:00

hello, when i make changes, to the website, the changes are only seen in internet explorer, how do i make the changes visible to other browsers?

I'm probably missing something but can't you just refresh the page? Perhaps you are talking about Browser Link? In that case Browser Link does not work with Content Security Policy (CSP) (See FilterConfig.cs) so you can turn off Browser Link or CSP temporarily to get one of them working. I have suggested a fix for this in MVC 6.

RehanSaeed
(edited )

Duncan Duncan commented on 2015-07-10 12:23:15

I'm probably missing something but can't you just refresh the page? Perhaps you are talking about Browser Link? In that case Browser Link does not work with Content Security Policy (CSP) (See FilterConfig.cs) so you can turn off Browser Link or CSP temporarily to get one of them working. I have suggested a fix for this in MVC 6.

yea, the project i have created using visual studio as you know, but when i run the project Internet Explorer being the default browser, the project runs as it should but when i run using other browsers say fire fox or chrome, the site does not run as i want, my site has a flash image, the image is visible on IE but not visible on chrome or firefox, the same thing happens even after i have published the site to the cloud

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-10 12:42:40

yea, the project i have created using visual studio as you know, but when i run the project Internet Explorer being the default browser, the project runs as it should but when i run using other browsers say fire fox or chrome, the site does not run as i want, my site has a flash image, the image is visible on IE but not visible on chrome or firefox, the same thing happens even after i have published the site to the cloud

Ah! Chrome and FireFox support CSP (See FilterConfig.cs) and are blocking flash by default. You just need to add an exception to allow your site to use flash plugins.

RehanSaeed

Duncan Duncan commented on 2015-07-10 12:44:52

Ah! Chrome and FireFox support CSP (See FilterConfig.cs) and are blocking flash by default. You just need to add an exception to allow your site to use flash plugins.

okay, thank you

RehanSaeed

Matt Matt commented on 2015-07-10 15:18:41

Hi,
I cannot get this to run on IIS 7.5. However, it runs fine on IIS express. Receive error below with IIS 7.5. I have all permissions set on project folders so this cannot be a permission issue. Any ideas?
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-10 15:29:42

Hi,
I cannot get this to run on IIS 7.5. However, it runs fine on IIS express. Receive error below with IIS 7.5. I have all permissions set on project folders so this cannot be a permission issue. Any ideas?
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Some Web.config settings do not exist in older versions of IIS (7.5 and 8) so you must edit the Web.config file and remove the setEtag="false" attribute, as well as the dynamicIpSecurity settings. I have added a note the ReadMe.html for future reference.

RehanSaeed
(edited )

Matt Matt commented on 2015-07-10 15:43:54

Some Web.config settings do not exist in older versions of IIS (7.5 and 8) so you must edit the Web.config file and remove the setEtag="false" attribute, as well as the dynamicIpSecurity settings. I have added a note the ReadMe.html for future reference.

That fix cleared up the Web.conig issues for me. Thanks!!

RehanSaeed

Matt Matt commented on 2015-07-28 16:55:41

So how do you run jquery script on the views using this template with CSP? Sorry new to CSP and trying to get a handle on it? Once I add script tags and document ready I get error:
Content Security Policy: The page's settings blocked the loading of a resource at self ("script-src http://localhost http://ajax.googleapis.com http://ajax.aspnetcdn.com").

$(document).ready(function () {...

How do I fix?
Thanks

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-28 17:21:08

So how do you run jquery script on the views using this template with CSP? Sorry new to CSP and trying to get a handle on it? Once I add script tags and document ready I get error:
Content Security Policy: The page's settings blocked the loading of a resource at self ("script-src http://localhost http://ajax.googleapis.com http://ajax.aspnetcdn.com").

$(document).ready(function () {...

How do I fix?
Thanks

No need to be sorry, CSP is pretty complicated. It looks like you are using an in-line script tag in your view, which is not allowed by default in CSP because its a security risk. To fix this problem you have two options:

  1. Move your script into a separate JavaScript file and link to it. This will work because you have the 'self' parameter set on your 'script-src' directive in your CSP policy. This is also best practice anyway.
  2. You can pass the 'unsafe-inline' parameter to the 'script-src' directive, which will allow in-line scripts to run but as the name implies it is unsafe and you will not be getting the full benefit of using CSP.
RehanSaeed

Matt Matt commented on 2015-07-28 17:28:08

I actually found your other blog about CSP and just read the piece how CSP blocks inline script. I moved it to site.js and all is fine now. I need to read more about CSP.
Thanks

RehanSaeed

Reza Rad Reza Rad commented on 2015-07-31 16:14:56

hi Rehan,

Thank you so much for answering my former question

Please be informed that there is a way that can turn off Custom error in web.config. that could therefore see yellow pages error in test program to localhost ?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-07-31 16:55:46

hi Rehan,

Thank you so much for answering my former question

Please be informed that there is a way that can turn off Custom error in web.config. that could therefore see yellow pages error in test program to localhost ?

You are talking about setting the customErrors mode to 'on' or 'off'. Please be careful, it is a serious security mistake to have mode set to 'off' in a live production site. The mode should be set to 'off' only for debugging purposes on your local machine. The Web.Release.config file sets the mode to 'on' for you.

RehanSaeed

Reza Rad Reza Rad commented on 2015-07-31 18:27:37

You are talking about setting the customErrors mode to 'on' or 'off'. Please be careful, it is a serious security mistake to have mode set to 'off' in a live production site. The mode should be set to 'off' only for debugging purposes on your local machine. The Web.Release.config file sets the mode to 'on' for you.

yeah you right,but i talking about debugging in local machine .In your template custom error is off but when error is happen show me error page instead of yellow page,how can be possible?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-08-02 18:44:32

yeah you right,but i talking about debugging in local machine .In your template custom error is off but when error is happen show me error page instead of yellow page,how can be possible?

Thanks for highlighting this issue Reza! I have created a fix for the next version. the httpErrors section in Web.config has an attribute called existingResponse which needs to be set to PassThrough in debug mode and Replace in release mode. I have also updated the Web.Release.config with the above transformation.

RehanSaeed
(edited )

G- G- commented on 2015-08-13 22:55:44

Hi Rehan, this is an awesome template, and helpful learning.

I am running into some problem with Web Api 2 (MVC5). In WebApiConfig.cs, these two lines are broken.

config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

I know now that maybe it is too early for me to use this template... But, is there anything I can, or need, to do specifically, to open my web api routes? I have kinda been stuck and my spinning wheels on this... Thanks, and great job!

G-

RehanSaeed

Founder Founder commented on 2015-08-14 12:19:29

Hi

Do you have a link to the latest vsix? Visual Studio Gallery is slow to update

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-08-14 19:31:36

Hi Rehan, this is an awesome template, and helpful learning.

I am running into some problem with Web Api 2 (MVC5). In WebApiConfig.cs, these two lines are broken.

config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

I know now that maybe it is too early for me to use this template... But, is there anything I can, or need, to do specifically, to open my web api routes? I have kinda been stuck and my spinning wheels on this... Thanks, and great job!

G-

What errors are you getting? Are you getting VS errors, browser errors, Elmah errors? A lot of people have trouble with CSP because it blocks things by default. See my blog post on CSP for more info and see your browser console for any errors.

Hope that helps.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-08-14 19:33:33

Hi

Do you have a link to the latest vsix? Visual Studio Gallery is slow to update

I assume you are talking about the ASP.NET 5 MVC 6 release which is version 2.0.0. I have to manually submit it to the VS gallery. I'm just doing some final testing, you will see it in a day or two :).

RehanSaeed

shahram iranian shahram iranian commented on 2015-08-21 07:55:30

thanks for u.
very good

RehanSaeed
(edited )

Diin Diin commented on 2015-08-25 00:10:13

I have now been able able to modify your boilerplate mvc5 and have added identity 2 - Int for userId and mysql as backend I had some hiccups like RenderActions were trying to redirect - to put backslash- I now found a way out. to comment whole controllers with [NoTrailingSlash]. Is that the way to go if one does not want the backslash for the whole application?

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-08-25 08:00:35

I have now been able able to modify your boilerplate mvc5 and have added identity 2 - Int for userId and mysql as backend I had some hiccups like RenderActions were trying to redirect - to put backslash- I now found a way out. to comment whole controllers with [NoTrailingSlash]. Is that the way to go if one does not want the backslash for the whole application?

Look at the RedirectToCanonicalUrlAttribute in FilterConfig.cs. Read the comments for the class and it will become clear.

RehanSaeed

Matt Matt commented on 2015-08-26 14:42:42

I am running into an issue displaying a pdf file in the browser using this template. In IE it always prompting to save instead displaying in browser. It seems to be related to this template as I can create new MVC web(non-boilerplate) app and use same code to display pdf and it works fine in all browsers. Is there a setting that would block this that I am missing somewhere?
Thanks

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-08-26 15:00:35

I am running into an issue displaying a pdf file in the browser using this template. In IE it always prompting to save instead displaying in browser. It seems to be related to this template as I can create new MVC web(non-boilerplate) app and use same code to display pdf and it works fine in all browsers. Is there a setting that would block this that I am missing somewhere?
Thanks

Take a look at the NWebSec XDownloadOptionsAttribute. It adds the X-Download-Options HTTP header. When users save the page, stops them from opening it and forces a save and manual open. ASP.NET Core Boilerplate is all about being secure by default but if you have a specific requirement then feel free to remove this HTTP header from specific areas where you need to open the PDF directly.

RehanSaeed

Matt Matt commented on 2015-08-26 15:16:21

I left it enabled for the site and for the one particular method I set [XDownloadOptions(Enabled=false)] and that seemed to be what I needed.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-08-26 15:20:53

I left it enabled for the site and for the one particular method I set [XDownloadOptions(Enabled=false)] and that seemed to be what I needed.

Cool, glad you got it sorted.

RehanSaeed

Matt Matt commented on 2015-09-08 22:03:23

How do you allow Google analytics to the csp settings?

RehanSaeed
(edited )

Jeremy Moore Jeremy Moore commented on 2015-09-08 23:01:44

I can only seem to run this in IIS Express from within Visual Studio. When I publish to localhost, it only displays a blank page. I tried commenting out the filers in the FilterConfig, but no luck. I am new to this stuff and have a feeling it's something very basic, but I can't seem to figure it out. Any help would be appreciated. Thanks for providing this great template!

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-09-09 06:36:59

How do you allow Google analytics to the csp settings?

You just need to add the Google Analytics URL to script-src. You can check the Chrome browsers console and it will tell you what you need exactly.

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-09-09 06:39:31

I can only seem to run this in IIS Express from within Visual Studio. When I publish to localhost, it only displays a blank page. I tried commenting out the filers in the FilterConfig, but no luck. I am new to this stuff and have a feeling it's something very basic, but I can't seem to figure it out. Any help would be appreciated. Thanks for providing this great template!

There are certain settings in the system.webServer section of Web.config that controls IIS, that are not available for older versions of IIS. See the Compatibility section of ReadMe.html.

RehanSaeed

Matt Matt commented on 2015-09-09 15:43:14

You just need to add the Google Analytics URL to script-src. You can check the Chrome browsers console and it will tell you what you need exactly.

Using Chrome I noticed that firebug is also being blocked: chrome-extension://bmagokdooijbeehmkpknfglimnifench/firebug-lite.js:15309 Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-09-09 16:34:19

Using Chrome I noticed that firebug is also being blocked: chrome-extension://bmagokdooijbeehmkpknfglimnifench/firebug-lite.js:15309 Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content

That makes perfect sense. FireBug is injecting script into the page. It's worth noting CSP blocks a lot of stuff like this e.g. evil government/ISP/router/Proxy injected scripts and browser extensions. Most of the time, this is exactly what you want...except this time.

You should stick to using the standard browser developer tools (I personally have always found FireBug to be a bit slow so I ditched it). I wouldn't recommend it but you could also disable CSP temporarily or remove it entirely.

RehanSaeed

Jeremy Moore Jeremy Moore commented on 2015-09-09 21:58:10

There are certain settings in the system.webServer section of Web.config that controls IIS, that are not available for older versions of IIS. See the Compatibility section of ReadMe.html.

Works! Should've read that doc better. Thanks for replying so fast and not calling me a nitwit for missing it in the readme file!

RehanSaeed

Rob M Rob M commented on 2015-09-30 10:44:25

Are you planning to make it a layered architecture or domain design, which will be a little bit cleaner I believe.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-09-30 14:23:18

Are you planning to make it a layered architecture or domain design, which will be a little bit cleaner I believe.

I'm not sure exactly what you are asking. There is not really much code in the project templates to add any layers. I've tried to keep it as simple as possible and only writing services where I absolutely need them. All services use IoC and are fully testable.

I'm trying to break up the MVC 6 project template using a feature selection wizard so that you only get the bare minimum you want. The MVC 5 project will stay as is for now. I'm still in the process of splitting off things into features you can select.

RehanSaeed

Rob M Rob M commented on 2015-10-02 14:09:21

I think this solution is more comprehensive than the one suggested by Patrick. Although that layered breakdown is what I would like to see in this solution.

I am moving things such as services etc. to their own class library projects and that makes this template look much cleaner, hence I suggested/asked that.

Anyway, thanks for the suggestion :-)

RehanSaeed
(edited )

Matt Matt commented on 2015-10-13 20:15:12

Using your template for a 2nd time, it's nice :). My next project utilizes telerik mvc controls. I added all the kendo CDN scripts and set the domain for kendo cdn property in CspScriptSrcAttribute. Facing an error "Error: Invalid template:'" for the kendo scripts. Have you seen this? Any work around other than setting unsafeeval false?
Thanks

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-10-14 09:53:22

Using your template for a 2nd time, it's nice :). My next project utilizes telerik mvc controls. I added all the kendo CDN scripts and set the domain for kendo cdn property in CspScriptSrcAttribute. Facing an error "Error: Invalid template:'" for the kendo scripts. Have you seen this? Any work around other than setting unsafeeval false?
Thanks

If CSP is causing any problems, the browser will tell you in the F12 developer tools console. It will even tell you how to change your CSP policy to fix the problem. If this is MVC 5, you should also see an error appear in Elmah.

RehanSaeed

Valentin Valentin commented on 2015-10-22 10:34:54

Great work man.
Keep it up!

RehanSaeed

Laurentiu Laurentiu commented on 2015-10-23 14:18:32

Hi,

Is Boilerplate multi-model friendly?
What I want to say? In real life apps, we have this kind of scenario: on views (starting with Index) we need to pull and render data from various models at a time (e.g. data from data from Candidates and Employers tables) and even mode from their "child" models. Obvious we do this with ViewModel(s) manually, but is not always as easy as we can espect and is prone to errors. Not to mention the entry/edit data scenario when we have to deal with more than the main model (e.g. an entry form with more than one "child" subforms).

Thnx.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-10-26 07:00:11

Hi,

Is Boilerplate multi-model friendly?
What I want to say? In real life apps, we have this kind of scenario: on views (starting with Index) we need to pull and render data from various models at a time (e.g. data from data from Candidates and Employers tables) and even mode from their "child" models. Obvious we do this with ViewModel(s) manually, but is not always as easy as we can espect and is prone to errors. Not to mention the entry/edit data scenario when we have to deal with more than the main model (e.g. an entry form with more than one "child" subforms).

Thnx.

It's annoying but creating your own ViewModel is the best way. Alternatively, you can sacrifice a tiny bit of performance and use the ViewBag. I don't think there is much I can do to improve this situation.

RehanSaeed

Lincoln Pires Lincoln Pires commented on 2015-11-04 10:27:45

Hi,

Could you please post a change log, when you update the template?

Tks!

The correct link is under the header "Release Notes and To-Do List" above.

RehanSaeed
(edited )

Matt Matt commented on 2015-11-16 22:05:46

Hi, I ran across another issue using this template. I am using identity 2.0 and create a user and generate email confirmation token that sends to user's email for them to verify. The issue I am seeing is that when verifying the email, the token is always invalid. I noticed when debugging the confirmemail action that the token comes back as a lowered string which is why it is invalid. Would this be caused from RouteTable.Routes.LowercaseUrls and or routes.LowercaseUrls = true? Please advise?
Thanks

RehanSaeed
(edited )

Matt Matt commented on 2015-11-17 13:50:47

Hi, I ran across another issue using this template. I am using identity 2.0 and create a user and generate email confirmation token that sends to user's email for them to verify. The issue I am seeing is that when verifying the email, the token is always invalid. I noticed when debugging the confirmemail action that the token comes back as a lowered string which is why it is invalid. Would this be caused from RouteTable.Routes.LowercaseUrls and or routes.LowercaseUrls = true? Please advise?
Thanks

I ended up solving my issue by sitting RedirectToCanonicalUrlAttribute properties for my controller method. Might want to update read me to state that identity email confirmation tokens will fail confirmation with "invalid token" error if the lowercaseUrls is not set for the confirm email method.
Thanks

RehanSaeed

Jan Larsen Jan Larsen commented on 2015-11-25 11:13:45

No need to be sorry, CSP is pretty complicated. It looks like you are using an in-line script tag in your view, which is not allowed by default in CSP because its a security risk. To fix this problem you have two options:

  1. Move your script into a separate JavaScript file and link to it. This will work because you have the 'self' parameter set on your 'script-src' directive in your CSP policy. This is also best practice anyway.
  2. You can pass the 'unsafe-inline' parameter to the 'script-src' directive, which will allow in-line scripts to run but as the name implies it is unsafe and you will not be getting the full benefit of using CSP.

Hello

Could you please elborate on how this "Move your script into a separate JavaScript file and link to it. This will work because you have the self parameter set on your script-src directive in your CSP policy. This is also best practice anyway." is done. I'm pretty new to js and i have added Identity framework to you solution but my log out link on the default _LoginPartial.cshtml wount execute...... Actual i can't get any script to execute on others pages as well.... what am i missing?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2015-12-04 08:47:10

Hello

Could you please elborate on how this "Move your script into a separate JavaScript file and link to it. This will work because you have the self parameter set on your script-src directive in your CSP policy. This is also best practice anyway." is done. I'm pretty new to js and i have added Identity framework to you solution but my log out link on the default _LoginPartial.cshtml wount execute...... Actual i can't get any script to execute on others pages as well.... what am i missing?

I recommend you spend some time learning about JavaScript and CSP to save you time in the long run.

RehanSaeed

Bernd Bernd commented on 2015-12-14 15:35:32

If CSP is causing any problems, the browser will tell you in the F12 developer tools console. It will even tell you how to change your CSP policy to fix the problem. If this is MVC 5, you should also see an error appear in Elmah.

Telerik Ui for MVC is opening securitiy holes.
If you want to compile templates, enable "unsafe-eval". As stated here: http://docs.telerik.com/kendo-ui/troubleshoot/content-security-policy
Besides that the HTML helper is gnereating inline script. you need to enable unsafe-inline too.

RehanSaeed

Matt Matt commented on 2015-12-17 14:09:15

Added identity and owin to my project and I'm testing login page with a return url and I keep getting a login loop. I tested the same in a regular MVC project with identity installed and do not get this issue. Any setting I may have missed that would cause this?

RehanSaeed

Matt Matt commented on 2015-12-17 15:55:46

The login loop has something to do with add seo optimization filter.

RehanSaeed
(edited )

Matt Matt commented on 2015-12-17 16:07:04

routes.LowercaseUrls = true in routeconfig will cause a login loop when using a redirect url.

RehanSaeed
(edited )

Kerem Kerem commented on 2015-12-24 12:41:22

Hi Rehan,

There is a problem in MVC6 RC1 Update 1 template. RazorPreCompileModule throws missing assembly error. I've added Microsoft.AspNet.Razor.Runtime.Precompilation to dependencies and added a using line for it in RazorPreCompilation.cs. That fixed the problem.

Great template. Thanks for your efforts.

RehanSaeed
(edited )

JFL JFL commented on 2016-01-05 23:00:44

routes.LowercaseUrls = true in routeconfig will cause a login loop when using a redirect url.

Hi Matt

Did you solve it?
In Login.cshtml i changed my Html.BeginForn to:

@using (Html.BeginForm("Login", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))

And added(note returnurl is lowercase):

@Html.Hidden("returnurl", new { returnurl = ViewBag.ReturnUrl })

Btw. Have you solved the problem where the logoff feature is not working(Does not fire)?
The current code looks like this:

using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
    @Html.AntiForgeryToken()

    @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })

    [Log off](document.getElementById('logoutForm').submit())
}

I'm sure it hase something to do with javascript:document.getElementById('logoutForm').submit() and CSP but trying to move it to site.js has not helped me... Anyone?

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2016-01-07 16:19:01

routes.LowercaseUrls = true in routeconfig will cause a login loop when using a redirect url.

I've updated the NuGet package to include a new NoLowercaseQueryStringAttribute attribute. This should be applied to the AccountController if you are using ASP.NET Identity. You will then no longer have any problems.

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2016-01-07 16:28:09

Hi Matt

Did you solve it?
In Login.cshtml i changed my Html.BeginForn to:

@using (Html.BeginForm("Login", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))

And added(note returnurl is lowercase):

@Html.Hidden("returnurl", new { returnurl = ViewBag.ReturnUrl })

Btw. Have you solved the problem where the logoff feature is not working(Does not fire)?
The current code looks like this:

using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
    @Html.AntiForgeryToken()

    @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })

    [Log off](document.getElementById('logoutForm').submit())
}

I'm sure it hase something to do with javascript:document.getElementById('logoutForm').submit() and CSP but trying to move it to site.js has not helped me... Anyone?

I've updated the NuGet package to include a new NoLowercaseQueryStringAttribute attribute. This should be applied to the AccountController if you are using ASP.NET Identity. You will then no longer have any problems.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2016-01-07 16:55:44

Hi Rehan,

There is a problem in MVC6 RC1 Update 1 template. RazorPreCompileModule throws missing assembly error. I've added "Microsoft.AspNet.Razor.Runtime.Precompilation" to dependencies and added a using line for it in RazorPreCompilation.cs. That fixed the problem.

Great template. Thanks for your efforts.

Thanks, that will be fixed in the next update.

RehanSaeed

jfl jfl commented on 2016-01-07 18:14:03

I've updated the NuGet package to include a new NoLowercaseQueryStringAttribute attribute. This should be applied to the AccountController if you are using ASP.NET Identity. You will then no longer have any problems.

Is the logoff also solved when using identity?

RehanSaeed
(edited )

Matt Matt commented on 2016-01-07 18:39:49

Hi Matt

Did you solve it?
In Login.cshtml i changed my Html.BeginForn to:

@using (Html.BeginForm("Login", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))

And added(note returnurl is lowercase):

@Html.Hidden("returnurl", new { returnurl = ViewBag.ReturnUrl })

Btw. Have you solved the problem where the logoff feature is not working(Does not fire)?
The current code looks like this:

using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
    @Html.AntiForgeryToken()

    @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })

    [Log off](document.getElementById('logoutForm').submit())
}

I'm sure it hase something to do with javascript:document.getElementById('logoutForm').submit() and CSP but trying to move it to site.js has not helped me... Anyone?

I'm not having any issues with logging off.

RehanSaeed

JFL JFL commented on 2016-02-09 22:35:11

I am using paypal in my application buy nothing happen when im calling return Redirect("https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=mytoken") (mytoken removed). If i use the link in browser paypal is called correctly

What should i do to be able to call external websites with this template?

Love the template btw.

Okay i revisited the problem an found out this is the problem:
Refused to send form data to 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-6P' because it violates the following Content Security Policy directive: "form-action 'self'".

Where du i update the template to accept redirects to paypal?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2016-02-10 08:26:07

Okay i revisited the problem an found out this is the problem:
Refused to send form data to 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-6P' because it violates the following Content Security Policy directive: "form-action 'self'".

Where du i update the template to accept redirects to paypal?

You need to change your CSP form-action directive to also allow form submissions to Paypal in your case. If you look at the Console in the Chrome F12 developer tools, it should tell you what URL you need to add to the directive.

RehanSaeed

jfl jfl commented on 2016-02-10 09:11:04

You need to change your CSP form-action directive to also allow form submissions to Paypal in your case. If you look at the Console in the Chrome F12 developer tools, it should tell you what URL you need to add to the directive.

It's in the CspFormActionAttribute filtet in the FilterConfig file, correct?

RehanSaeed

Matthew Matthew commented on 2016-02-18 22:54:00

Hi Rehan,
I know you've addressed this issue but I am still unable to get it to work. "Logoff"

using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))`

I've added the attributes but still does not trigger.
I've tried various on the following by removing and/or adding attributes. I've also create the constants file for Account by emulating Home. Not sure what else to try. Help please.

[NoLowercaseQueryString]
[Authorize]
public class AccountController : Controller{...}

[NoLowercaseQueryString]
[HttpPost]
[ValidateAntiForgeryToken]
[Route("Account", Name = AccountControllerRoute.GetLogOff)]
public ActionResult LogOff(){...}
RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2016-02-19 10:24:20

Hi Rehan,
I know you've addressed this issue but I am still unable to get it to work. "Logoff"

using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))

I've added the attributes but still does not trigger.
I've tried various on the following by removing and/or adding attributes. I've also create the constants file for Account by emulating Home. Not sure what else to try. Help please.

[NoLowercaseQueryString]
[Authorize]
public class AccountController : Controller{...}

[NoLowercaseQueryString]
[HttpPost]
[ValidateAntiForgeryToken]
[Route("Account", Name = AccountControllerRoute.GetLogOff)]
public ActionResult LogOff(){...}

Have you tried removing the RedirectToCanonicalUrlAttribute filter to make sure that it really is the thing causing the issue? If you can raise an issue on GitHub and provide a sample, I'll take a look.

RehanSaeed

Md. Dinar Md. Dinar commented on 2016-04-28 04:48:58

Hi,

Could you please post a change log, when you update the template?

Tks!

It's a nice solution for public applications. But while I am migrating to this architecture I can't login using identity framework. In debug mode I can see the login is successful but the the authorization fails immediately. What should I do to recover this.

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2016-04-28 08:32:45

It's a nice solution for public applications. But while I am migrating to this architecture I can't login using identity framework. In debug mode I can see the login is successful but the the authorization fails immediately. What should I do to recover this.

I talk about how to use ASP.NET Identity in the ReadMe.html file. Basically you need to add an attribute to a controller.

RehanSaeed

Mindy Mindy commented on 2016-05-02 15:51:26

While you're move ASP MVC 6, I do not see any user/developer friendly updates on the on the previous version. Many of us are using the previous version.

  1. Can you please update the documentation,
  2. Can you add comments on which of the IOC is needed and what they do,
  3. The route handlers same issue.
  4. A check list - verification if we did succeed in getting them correctly configured.
  5. I would like to see ASP Identity baked in with best practises, since it is a MS version
  6. Why is Nweb all over - is there one central approach on this
  7. how can we update as a new version comes out - this is also not easy to do

thanks

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2016-05-03 14:52:03

While you're move ASP MVC 6, I do not see any user/developer friendly updates on the on the previous version. Many of us are using the previous version.

  1. Can you please update the documentation,
  2. Can you add comments on which of the IOC is needed and what they do,
  3. The route handlers same issue.
  4. A check list - verification if we did succeed in getting them correctly configured.
  5. I would like to see ASP Identity baked in with best practises, since it is a MS version
  6. Why is Nweb all over - is there one central approach on this
  7. how can we update as a new version comes out - this is also not easy to do

thanks

Thanks for asking:

  1. What are you having trouble with?
  2. The MVC 5 template uses Autofac out of the box.
  3. Not sure what you mean. Some people don't understand attribute routing, I suggest reading the articles at http://asp.net on the subject.
  4. Getting what configured? There is already a check-list in the ReadMe.html file with everything you need to do.
  5. I'm working on it.
  6. NWebSec is used for security.
  7. Update NuGet packages and keep an eye on the Release Notes and changesets on GitHub.

Hope that helps. If you find any issues, please raise one on GitHub.

RehanSaeed

Diin Diin commented on 2016-05-14 16:50:53

I have been using your mvc5 boiler template and I have been able to add identity etc everything working fine thanks. I have to use hangfire and postal to run background scripts and send emails but this is getting issues with missing HttpContext -
I have found out that Autofac and Glimpse are the culprits.
I get this error An exception of type 'System.InvalidOperationException' occurred in Autofac.Integration.Mvc.dll but was not handled in user code

Are you able to assist me in this regards- how to give exceptions or allow hangfire and postal to work without HttpContext in the background.

Additional information: The request lifetime scope cannot be created because the HttpContext is not available. How do i

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2016-05-16 12:27:55

I have been using your mvc5 boiler template and I have been able to add identity etc everything working fine thanks. I have to use hangfire and postal to run background scripts and send emails but this is getting issues with missing HttpContext -
I have found out that Autofac and Glimpse are the culprits.
I get this error An exception of type 'System.InvalidOperationException' occurred in Autofac.Integration.Mvc.dll but was not handled in user code

Are you able to assist me in this regards- how to give exceptions or allow hangfire and postal to work without HttpContext in the background.

Additional information: The request lifetime scope cannot be created because the HttpContext is not available. How do i

I think you should probably contact hangfire or maybe Autofac about this issue.

RehanSaeed

Zach Zach commented on 2017-01-09 16:36:08

I'm using the ASP.NET MVC 5 template and was unable to get the fallback css (FontAwesome) to work properly. I changed the code to the following to get it to work in case anyone else encounters this problem. Really like the template!

test: function (meta) {
     return window.getComputedStyle(meta, null).getPropertyValue('font-family') === 'FontAwesome';
},
RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-01-09 17:09:26

I'm using the ASP.NET MVC 5 template and was unable to get the fallback css (FontAwesome) to work properly. I changed the code to the following to get it to work in case anyone else encounters this problem. Really like the template!

test: function (meta) {
     return window.getComputedStyle(meta, null).getPropertyValue('font-family') === 'FontAwesome';
},

Your fix is being included. Please log an issue on GitHub next time. Thanks!

RehanSaeed

vlado vlado commented on 2017-01-31 01:11:21

Rehan, I really like your boilerplate and would like to move my existing project into it. But I use Bootstrap 4 beta and cannot find the place in the project where to replace the version 3. Would you please let me know how is it set?
Thanks.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-01-31 14:45:54

Rehan, I really like your boilerplate and would like to move my existing project into it. But I use Bootstrap 4 beta and cannot find the place in the project where to replace the version 3. Would you please let me know how is it set?
Thanks.

Take a look at the Bootstrap v4 documentation for how to integrate it. It should be very similar to v3.

RehanSaeed

avi newman avi newman commented on 2017-02-18 23:04:04

I tried loading the solution using a fresh install of VS 2015 Community. The project "TemplateJsonToMarkdown" failed to load. http://imgur.com/a/CG7N6

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-02-19 08:03:42

I tried loading the solution using a fresh install of VS 2015 Community. The project "TemplateJsonToMarkdown" failed to load. http://imgur.com/a/CG7N6

It's just a tool that the project uses to generate some markdown. You can ignore that project.

RehanSaeed

Cory Cory commented on 2017-03-04 04:20:10

Hey Rehan, The latest template project download wouldn't compile for me. I needed to add the following references to the FilterConfig.cs file.

using Boilerplate.Web.Mvc.Filters;     
using NWebsec.Mvc.HttpHeaders;
using NWebsec.Mvc.HttpHeaders.Csp;
RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-03-04 13:09:16

Hey Rehan, The latest template project download wouldn't compile for me. I needed to add the following references to the FilterConfig.cs file.

using Boilerplate.Web.Mvc.Filters;     
using NWebsec.Mvc.HttpHeaders;
using NWebsec.Mvc.HttpHeaders.Csp;

Thats strange, are you sure? I've not touched that template in some time.

RehanSaeed

Cory Cory commented on 2017-03-04 16:19:04

Thats strange, are you sure? I've not touched that template in some time.

Yes, I thought it was strange too. I'm using the MVC 5 template. Happens in VS 2013 and VS 2015.

RehanSaeed

abdelmonem Mohammad abdelmonem Mohammad commented on 2017-03-20 11:51:55

Let me call you Mr. giant. Very generous. I'm proud of you and of your name , Muhamad Rehan And Saeed(happy inshaallah). A lot of thanks.

RehanSaeed

abdelmonem Mohammad abdelmonem Mohammad commented on 2017-03-24 09:13:59

I'm not sure what you mean. Can you explain further?

Thank you for your response. I once read that when you write the internal URL of a page as if it were a link to another site using '...a href=http://www.sitename.com/pageURL....' , this will give that page a link juice in google search engine. Allah bless you and your family for your kindness. Three years ago you wrote this and still caring for people asking you.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-03-27 16:54:27

Thank you for your response. I once read that when you write the internal URL of a page as if it were a link to another site using '...a href=http://www.sitename.com/pageURL....' , this will give that page a link juice in google search engine. Allah bless you and your family for your kindness. Three years ago you wrote this and still caring for people asking you.

I've not read the same thing. Using the full URL to pages in your own site shouldn't have any effect in theory.

RehanSaeed

abdelmonem Mohammad abdelmonem Mohammad commented on 2017-03-29 07:19:46

I've not read the same thing. Using the full URL to pages in your own site shouldn't have any effect in theory.

Thank you very much. I have benefited from you a lot Mr. Giant. I can't reward you but I hope Allah reward you.

RehanSaeed

Ricky Ricky commented on 2017-04-21 12:56:15

such an awesome boilerplate template and thank you very much for creating it!! a couple of questions

  1. With the constants for the route names (should these be manually maintained every time I decide to add/update a route?), why not something like T4MVC?
  2. Can I start contributing to the github repo and create pull requests, is there anything I need to look out for/follow?

Cheers,
Ricky

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-04-21 14:01:20

such an awesome boilerplate template and thank you very much for creating it!! a couple of questions

  1. With the constants for the route names (should these be manually maintained every time I decide to add/update a route?), why not something like T4MVC?
  2. Can I start contributing to the github repo and create pull requests, is there anything I need to look out for/follow?

Cheers,
Ricky

  1. T4 is not supported for .NET Core. There is an issue in the repo about it you can look at for more info.
  2. Yes, any time. There is a contributing guide in the repo.
RehanSaeed

AbdelMonem AbdelMonem commented on 2017-05-18 15:08:30

With great thanks to you. I have 3 issues with boilerplate that I can't fix in google pgespeed insights:
1- Eliminate render-blocking JavaScript and CSS in above-the-fold content
2- Leverage browser caching
3- Reduce server response time

Would you please find us a solution for these?

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-05-18 15:21:13

With great thanks to you. I have 3 issues with boilerplate that I can't fix in google pgespeed insights:
1- Eliminate render-blocking JavaScript and CSS in above-the-fold content
2- Leverage browser caching
3- Reduce server response time

Would you please find us a solution for these?

  1. Move JavaScript to the bottom of the page.
  2. Use ResponseCache in ASP.NET Core or OutputCache in ASP.NET MVC 5
  3. Get a more powerful server.
RehanSaeed
(edited )

AbdelMonem AbdelMonem commented on 2017-05-18 16:26:16

  1. Move JavaScript to the bottom of the page.
  2. Use ResponseCache in ASP.NET Core or OutputCache in ASP.NET MVC 5
  3. Get a more powerful server.

Very generous. Thank you for the quick response and for your generosity.

RehanSaeed
(edited )

AbdelMonem AbdelMonem commented on 2017-05-23 22:44:32

  1. Move JavaScript to the bottom of the page.
  2. Use ResponseCache in ASP.NET Core or OutputCache in ASP.NET MVC 5
  3. Get a more powerful server.

Sorry for burdening you with too many questions. I failed to find a solution for the problem of css. I have 6 sites all have that same issue and of course I designed them all using your wonderful boilerplate. They are :
https://www.housecleanned.com/
https://www.cleanhousess.com/
https://www.cleanhousees.com/
https://www.housecleansed.com/
https://www.cleanhousee.com/
http://www.alnazafa.com/
for your kind reference, if possible.
I have an older site that is not designed using boilerplate but has not any issue. I wonder why. Also for your kind reference : www.kfsedu.gov.eg

Because since your last kind answer, I have been trying and trying to solve that issue, but in vain.
Thanks in advance and we hope that Allah bless you and all your family for your kindness.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-05-24 09:19:47

Sorry for burdening you with too many questions. I failed to find a solution for the problem of css. I have 6 sites all have that same issue and of course I designed them all using your wonderful boilerplate. They are :
https://www.housecleanned.com/
https://www.cleanhousess.com/
https://www.cleanhousees.com/
https://www.housecleansed.com/
https://www.cleanhousee.com/
http://www.alnazafa.com/
for your kind reference, if possible.
I have an older site that is not designed using boilerplate but has not any issue. I wonder why. Also for your kind reference : www.kfsedu.gov.eg

Because since your last kind answer, I have been trying and trying to solve that issue, but in vain.
Thanks in advance and we hope that Allah bless you and all your family for your kindness.

Look into Content Security Policy (CSP). I wrote a blog post talking about it, the template contains links. Inline script tags are blocked by default, you need to use external css files. I'm just guessing what the problem could be.

RehanSaeed

AbdelMonem AbdelMonem commented on 2017-05-26 13:39:39

Look into Content Security Policy (CSP). I wrote a blog post talking about it, the template contains links. Inline script tags are blocked by default, you need to use external css files. I'm just guessing what the problem could be.

Thank you for your kindness and for your time. I am so grateful.

RehanSaeed

Boncho Valkov Boncho Valkov commented on 2017-06-28 12:06:35

This template is very good, but if you want to good architecture you still have to spend a lot of time separating everything in different projects and etc.
I found a very good template engine application, that gives you all of that separation and a lot more thing out of the box.
Curretnly it is still in beta, but it you can download freely MVC templates. It provides good backend architecture.

http://asptemplatestack.com/Templates/GetAll

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-06-28 16:26:06

This template is very good, but if you want to good architecture you still have to spend a lot of time separating everything in different projects and etc.
I found a very good template engine application, that gives you all of that separation and a lot more thing out of the box.
Curretnly it is still in beta, but it you can download freely MVC templates. It provides good backend architecture.

http://asptemplatestack.com/Templates/GetAll

Why would you need to separate anything into a separate project? Everything in the Boilerplate templates is super simple. I can only guess that you've not tried it and want to advertise the asptemplatesstack which is perfectly fine! Whatever is useful to people is good.

RehanSaeed

AbdelMonem AbdelMonem commented on 2017-07-26 06:19:30

Mr. Mohammad, when I look at google analytics for my site I find the same page with two separate analytics; one in capital letters and its same copy in small letters. Why two pages for the same webpage. I'm using your boilerplate.If you please, help me as we are used to from your kindness.

RehanSaeed
(edited )

AbdelMoneim AbdelMoneim commented on 2017-08-24 21:44:55

If you please Mr. Mohammad, when I used your boilerplate it generated the robots.txt and the sitemap.xml as you explained, but when I used SSL certificate, the site moved from http to https and the robots.txt and the sitemap.xml have the old http. How can I update these in google search console? I hope this question is not deleted as done before with two or more questions. Thanks.

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-09-12 14:28:53

If you please Mr. Mohammad, when I used your boilerplate it generated the robots.txt and the sitemap.xml as you explained, but when I used SSL certificate, the site moved from http to https and the robots.txt and the sitemap.xml have the old http. How can I update these in google search console? I hope this question is not deleted as done before with two or more questions. Thanks.

If the request is made using HTTPS and you are using the IUrlHelper to generate URL's then all URL's generated will start with HTTPS.

RehanSaeed
(edited )

Aburomman Aburomman commented on 2017-12-18 13:27:56

If the request is made using HTTPS and you are using the IUrlHelper to generate URL's then all URL's generated will start with HTTPS.

Hi, how to implement this IUrlHelper and where to get it?

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2017-12-21 09:23:51

Hi, how to implement this IUrlHelper and where to get it?

It's in the Boilerplage NuGet package.

RehanSaeed

AbdelMoneim AbdelMoneim commented on 2017-12-21 17:14:33

It's in the Boilerplage NuGet package.

When I moved to boilerplate my sites lost their rank, fifth or sixth pages, of course as a result of my inability. But I lost hope how to deal with my sites and boilerplate.
The problem is that the sitemap in the site is http whereas the pages are https.
The sites appear in good rank in search console but never appear in search pages.
https://www.housecleanned.com
https://www.cleanhousess.com
https://www.housecleansed.com
https://www.alrahwajan.com
http://www.alnazafa.com
Sorry for burdening you, I hope there is a time when I find myself entering here only to send you regards not asking so much like that.
Best regards and best wishes.

RehanSaeed
(edited )

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2018-01-03 09:23:37

When I moved to boilerplate my sites lost their rank, fifth or sixth pages, of course as a result of my inability. But I lost hope how to deal with my sites and boilerplate.
The problem is that the sitemap in the site is http whereas the pages are https.
The sites appear in good rank in search console but never appear in search pages.
https://www.housecleanned.com
https://www.cleanhousess.com
https://www.housecleansed.com
https://www.alrahwajan.com
http://www.alnazafa.com
Sorry for burdening you, I hope there is a time when I find myself entering here only to send you regards not asking so much like that.
Best regards and best wishes.

You need to make sure your link to your sitemap in your robots.txt file starts with https. Hope that helps.

RehanSaeed
(edited )

AbdelMoneim AbdelMoneim commented on 2018-01-10 04:34:31

Dear MR. Mohammad Rehan, thank you for your kindness and for your time. But the robots.txt itself is automatically generated and I do not know how to interfere to change its links. The links in sitemap.xml are http and in robots.txt are http too.

RehanSaeed

AbdelMoneim AbdelMoneim commented on 2018-01-26 13:23:49

Dear MR. Mohammad Rehan, thank you for your kindness and for your time. But the robots.txt itself is automatically generated and I do not know how to interfere to change its links. The links in sitemap.xml are http and in robots.txt are http too.

Dear Mr.Mohammad Rehan,
At last I got the explanation and the solution for the problem.
When I started boilerplate template ten months ago, the problem was that the links of the site were http only whereas the site was https.
I used to use cloudflare free SSL.
Here is the problem. Free SSL from cloudflare makes an infinite loop between cloudflare and the server hosting the site files. And the connection between the two is doubled; the visitor or search engine reads from cloudflare https while cloudflare itself reads http from the server hosting the files.
When I bought an SSL, the connection between the visitor and cloudflare is https as used to be, but the connection between cloudflare hosting the certificate and the server hosting the files became https too.
When I submitted the new sitemap to google it read it https links.
Thank you very much Mr. giant. Allah bless you and your family.

RehanSaeed

Methab Methab commented on 2018-01-31 06:34:50

SOCIAL MEDIA SUPPORT
Open Graph meta tags and Twitter Card meta tags are included by default. Not only that but ASP.NET Core Boilerplate includes fully documented HTML helpers that allow you to easily generate Open Graph object or Twitter Card met* tags easily and correctly.

I think you needed to write meta here.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2018-02-12 09:08:36

SOCIAL MEDIA SUPPORT
Open Graph meta tags and Twitter Card meta tags are included by default. Not only that but ASP.NET Core Boilerplate includes fully documented HTML helpers that allow you to easily generate Open Graph object or Twitter Card met* tags easily and correctly.

I think you needed to write meta here.

Fixed

RehanSaeed

AbdelMoneim AbdelMoneim commented on 2018-05-04 17:14:27

Dear MR. Mohammad Rehan,
Once again I burden you with my questions, so please be patient with me.
I created a new boilerplate web project, and directly uploaded it to my account on the host server and checked it with google's "PageSpeed Insight", and it was only 63 out of 100. The suggestions were 'Enable compression' and 'Eliminate render-blocking JavaScript and CSS'.
How can I overcome these? Thanks in advance Mr. Giant.

RehanSaeed

René René commented on 2018-06-25 04:58:54

At which point will you be updating the MVC 5 boilerplate to Bootstrap 4? Alternatively, could you make Bootstrap (and anything else that exists as a NuGet package) a dependency so that we can ensure it remains updated without relying on your own updates?

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2018-06-25 09:16:41

At which point will you be updating the MVC 5 boilerplate to Bootstrap 4? Alternatively, could you make Bootstrap (and anything else that exists as a NuGet package) a dependency so that we can ensure it remains updated without relying on your own updates?

I have stopped developing the MVC 5 project template and am focusing on ASP.NET Core project templates. To upgrade to Bootstrap 4, I suggest, following the Bootstrap guide on their website. Also, since these are project templates, the idea is that you are supposed to customize them to your needs. While I try to move as much functionality to NuGet packages as possible, I can't do that for everything.

RehanSaeed

René René commented on 2018-06-29 00:50:13

I have stopped developing the MVC 5 project template and am focusing on ASP.NET Core project templates. To upgrade to Bootstrap 4, I suggest, following the Bootstrap guide on their website. Also, since these are project templates, the idea is that you are supposed to customize them to your needs. While I try to move as much functionality to NuGet packages as possible, I can't do that for everything.

Okay, I am currently looking into the Core project. However, I am noticing that it is built under netcoreapp1.1, and not the latest netcoreapp2.1. Are you looking at putting out a netcoreapp2.1 version?

FYI, when I try to upgrade to netcoreapp2.1 (modifying *.csproj, etc.), I run into a few show-stopping errors, such as

KestrelServerOptions does not contain a definition for UseHttps and the best extension method overload ListenOptionsHttpsExtensions.UseHttps(ListenOptions, string, string) requires a receiver of type ListenOptions

And,

The type or namespace name HttpClient could not be found

And,

The type or namespace name HttpRequestException could not be found

The latter two being exclusively in the SiteMapPinger.

RehanSaeed

René René commented on 2018-06-29 06:23:52

Okay, I am currently looking into the Core project. However, I am noticing that it is built under netcoreapp1.1, and not the latest netcoreapp2.1. Are you looking at putting out a netcoreapp2.1 version?

FYI, when I try to upgrade to netcoreapp2.1 (modifying *.csproj, etc.), I run into a few show-stopping errors, such as

KestrelServerOptions does not contain a definition for UseHttps and the best extension method overload ListenOptionsHttpsExtensions.UseHttps(ListenOptions, string, string) requires a receiver of type ListenOptions

And,

The type or namespace name HttpClient could not be found

And,

The type or namespace name HttpRequestException could not be found

The latter two being exclusively in the SiteMapPinger.

Changing the Kestrel options in Program.cs to the commonly-suggested format:

options.Listen(IPAddress.Any, 443, listenOptions => listenOptions.UseHttps("DevelopmentCertificate.pfx", "password"));

did not address the issue, and caused an "access denied" error. In order to start the application even in debug mode, I had to comment out this option entirely. Strangely enough, that worked just fine, and I even had to manually/explicitly accept the self-signed certificate.

I had a few issues with the AntiForgery cookies and had to modify the following in ServiceCollectionExtensions.cs:

options.Cookie.Name = "f";
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;

In order to fix the SitemapPingerService.cs, I was unable to use other commonly-suggested options (AppContext.SetSwitch() did nothing), and had to modify the *.csproj itself:

C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.1\ref\netcoreapp2.1\System.Net.Http.dll

This does throw an error,

Found conflicts between different versions of System.Net.Http that could not be resolved.

But at least the application runs. This may also not be immediately correctable, as there is a known issue with HttpClient under Core 2.1: https://github.com/dotnet/corefx/issues/30166#issuecomment-395489603

I await your more experienced input, if you have any to provide.

RehanSaeed

René René commented on 2018-06-29 06:28:15

Changing the Kestrel options in Program.cs to the commonly-suggested format:

options.Listen(IPAddress.Any, 443, listenOptions => listenOptions.UseHttps("DevelopmentCertificate.pfx", "password"));

did not address the issue, and caused an "access denied" error. In order to start the application even in debug mode, I had to comment out this option entirely. Strangely enough, that worked just fine, and I even had to manually/explicitly accept the self-signed certificate.

I had a few issues with the AntiForgery cookies and had to modify the following in ServiceCollectionExtensions.cs:

options.Cookie.Name = "f";
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;

In order to fix the SitemapPingerService.cs, I was unable to use other commonly-suggested options (AppContext.SetSwitch() did nothing), and had to modify the *.csproj itself:

C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.1\ref\netcoreapp2.1\System.Net.Http.dll

This does throw an error,

Found conflicts between different versions of System.Net.Http that could not be resolved.

But at least the application runs. This may also not be immediately correctable, as there is a known issue with HttpClient under Core 2.1: https://github.com/dotnet/corefx/issues/30166#issuecomment-395489603

I await your more experienced input, if you have any to provide.

Okay, the XML for the *.csproj did not come through properly. I will try to re-enter it here:

<ItemGroup>
  <HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.1\ref\netcoreapp2.1\System.Net.Http.dll\</HintPath>
  </Reference>
</ItemGroup>

I tried to use backward slashes to escape the single angle brackets. Since I am unable to edit or otherwise re-do a comment, please eMail me directly for the XML if it doesn't show up.

RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2018-06-29 09:28:07

Okay, I am currently looking into the Core project. However, I am noticing that it is built under netcoreapp1.1, and not the latest netcoreapp2.1. Are you looking at putting out a netcoreapp2.1 version?

FYI, when I try to upgrade to netcoreapp2.1 (modifying *.csproj, etc.), I run into a few show-stopping errors, such as

'KestrelServerOptions' does not contain a definition for 'UseHttps' and the best extension method overload 'ListenOptionsHttpsExtensions.UseHttps(ListenOptions, string, string)' requires a receiver of type 'ListenOptions'

And,

The type or namespace name 'HttpClient' could not be found

And,

The type or namespace name 'HttpRequestException' could not be found

The latter two being exclusively in the SiteMapPinger.

Please see the GitHub repository. The .NET Core 2.1.1 templates are for a Swagger and GraphQL API. I don't currently have one for an MVC website and have not maintained the 1.1 template because so much technology changed. I do plan to build one again which will probably use Blazor and Webpack but not right now.

RehanSaeed

René René commented on 2018-07-03 19:09:47

Please see the GitHub repository. The .NET Core 2.1.1 templates are for a Swagger and GraphQL API. I don't currently have one for an MVC website and have not maintained the 1.1 template because so much technology changed. I do plan to build one again which will probably use Blazor and Webpack but not right now.

Ah, looks like I will have to muddle along with what you have been gracious enough to provide so far. So thank you very much. My needs are that of a back-end heavy development with very little to no front-end fanciness, so your new Dotnet-Boxed is a round peg to my square hole. Most of what I build are intranet sites, so bandwidth and server latency are not at issue.

RehanSaeed

Boncho Valkov Boncho Valkov commented on 2018-08-30 10:38:31

Why would you need to separate anything into a separate project? Everything in the Boilerplate templates is super simple. I can only guess that you've not tried it and want to advertise the asptemplatesstack which is perfectly fine! Whatever is useful to people is good.

Hi Rehan, if you want to expand and make parts of the projects independable and changeable you need to have some kind of project architecture.

RehanSaeed

All Tech Geeks All Tech Geeks commented on 2020-01-03 11:21:41

asp.net mvc boilerplate is very good, its open source and very confortable. now asp.net core 3 aslo available with angular 8