Having to select a template when creating a new project in Visual studio, which of the 2 should pick?("asp.net core web app" ...or... "asp.net core web app (model-view-controller)")
In order to try and discover the answer for myself, I'd have to create 2 different projects and compare the features and capabilities. If I knew what to look for, it might been easier.
if the on template is MVC, then what is the non-MVC actually then?
If I go for the one project, would I be able to convert to the other later then? (and vise versa)
The simplest explaination is: In asp.net core you work with web pages where each of the webpages (Razor pages) has a code behind file. In asp.net core web app (Model View Controller) your code behind is kind of centralised, in a controller file, and this code redirects to different view files. There is more to this than that. Furter explaination can be found on from page 12 of in this document: https://dotnet.microsoft.com/en-us/download/e-book/porting-aspnet-apps/pdf
Related
I've been using asp.net mv3 via vs 2010 for quite a while now, also the default views and actions generated when creating a controller are very helpful. However lately, i found it redundant to keep on adding the same stuff in the generate view, for example, i have to place "btn" class names on links and button, since im using a 3rd party css library. So, i was wondering if it was possible to customize the generated views so that i wouldn't have to add them anymore after generation of the view?
image --> http://i.stack.imgur.com/J8Aiz.png
Yes it's possible to customize the built in TT templates which used fot the scaffolding.
Here is a good how to: Modifying the default code generation/scaffolding templates in ASP.NET MVC
If you are more into scaffolding the MVC Scaffolding project could be also interesting for you.
I would like to make custom editor templates for different data types in ASP.NET MVC (to use with Html.EditorFor()), including rewriting the existing templates. The ultimate goal is to create a mini-framework where each editor supports javascript notifications about being changed, and I can show a message to the user that there are unsaved changes in the page. (Maybe there's something existing already?)
I can find many questions pertaining to problems with such templates, but nowhere can I find a tutorial or manual on creating them. Where do they go? Is there any special syntax? How does a template get selected? What information is available in the template and how do I access it? Etc.
So - where can I find out all about these templates?
Check and download ASP.NET MVC 3 Futures on http://aspnet.codeplex.com/releases/view/58781 and see how the default source code looks. Note: this works for MVC 4 as well.
First of all, when to use what and the overall differences between them has already been answered before. But I couldn't find an answer to this question:
Where can I check if my Visual Studio project is a Web Application or a Web Site?
The easiest way to differentiate between Web Site and Web Application is to look at the project's icons.
Web Site
has an icon without the used language
displays its physical root path
does not have a Properties folder
Web Application
has an icon including the used language
displays the project's name
has a Properties folder
To find out more about the technical differences between them ...
ASP.NET Web Site or ASP.NET Web Application?
Personally, one tell tale sign for me is whether the project folder actually contains a project file, or not.
You can see the icons differ slightly in VS - a web application has a layered world->docs->language icon and a web site just consists of world->docs.
Also, once opened within VS, right-clicking will display Properties and Property Pages for web applications and web sites respectively; further, on clicking this option you will be greeted with a dialog for the former and MDI tabbed form for the latter - the latter also exposes more functionality to control pre and post build steps and so forth.
A a web application will also display Properties and References special folders as part of the project tree in the Solution Explorer, whereas a web site does not necessarily; unless manually created for some reason (but they still won't be special - web sites use the bin folder for their references).
I recently found out (painfully) that web applications do not support Profiles which is not fun. Web sites however do support them and make life much easier. I noticed here people saying there are no major differences. This one is quite major and can make your life difficult if you select to make a web application instead of a web site.
Web application and Web Site are VS templates, nothing more. I doubt you will find this information directly somewhere in project. You can try to go through template differences list and guess how this particular project was created.
For Web Site project, once run (F5) you can change the code in the code-behind, the solution will allow it and it will compile on the fly when saved.
A Web Application project, however, will not allow this. This is the simplest way of being able to tell between the two.
Upon creating a new ASP.NET MVC 3 Razor site, there are 9 Account\*.cshtml files which seem to be views with the controller logic inserted at the top of the view in an anonymous code block. There is no account controller class.
Why is this? As I understood, the benefit of MVC was the separation of concerns of code & presentation. Does this imply that I should remove all of the existing files & re-implement the Authentication & Authorisation layers?
It seems odd that MS would ship the 'worst possible example' with their flagship web framework.
Thanks,
Jarrod
Edit: I was using the wrong entry point within visual studio to create the application (see my comment below). Thanks!
Hmm, something is not quite right on your end.
I just created a new ASP.NET MVC3 Web Application.
I do have a 'Controllers' folder with a proper AccountController as part of the project.
Are you using Visual Studio?
This is incorrect. Here's the default folder structure in the MVC3 Razor starter app:
As you can see, there are two controllers in the ~/Controllers folder.
Just to be clear, I started a new VS2010 instance, created a new MVC3 project, selected "Internet Application" and Razor as the view engine.
I'm going to create a website with lots of business logic, connected to a background data model. For these reasons I chose ASP.NET MVC3 as development platform.
Unfortunately, I left web programming at the time of the old ASP and JSP and lately I worked with windows applications and C#.
Now I'm wondering which is the best(easiest, fastest, most reliable, most compatible with browsers) technique to create user views?
I explored a little Razor, but it is unclear for me, is it a so good choice? Is it supported by forums or still too fresh?
I'm very tempted of using webcontrols since I'm now addicted to them. Would this be a good choice? Can I use webcontrols just in aspx or in razor as well?
What about Ajax controls? Would it be a better choice?
Thanks!
Yes, Razor is a good choice. See here for a pretty good summary.
As Robert mentioned, "controls" go against the MVC pattern and will not even work in Razor. You want html helpers for small bits of markup (for example, to render a text box) and partial views for more complicated things (like a shopping cart widget)
Use of AJAX depends on the UI needs of your application. Initially it would be simpler to start without AJAX. Also, some clients might have JavaScript disabled and then AJAX would not work.
"web controls" are not appropriate for MVC at all - they go against the MVC pattern. Instead, look into "partial views" for creating common bits of UI that get reused across multiple pages