RehanSaeed / rehansaeed.github.io

Muhammad Rehan Saeed's Blog
https://rehansaeed.com
30 stars 6 forks source link

[Comment] ASP.NET Core Boilerplate #58

Open RehanSaeed opened 4 years ago

RehanSaeed commented 4 years ago

https://rehansaeed.com/asp-net-mvc-boilerplate/

RehanSaeed commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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
  2. Changed the project properties - Anonymous Authentication -> Disabled and Windows Authentication -> Enabled

  3. 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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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
  2. Changed the project properties - Anonymous Authentication -> Disabled and Windows Authentication -> Enabled

  3. 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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

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

RehanSaeed commented 4 years ago

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 commented 4 years ago

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

how to add asp.net boilerplate template to visual studio

RehanSaeed commented 4 years ago

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 commented 4 years ago

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

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

RehanSaeed commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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?