ASP.NET websites are compiled but with more HTML markup generated! - asp.net

Everytime I view the source of ASP.NET website I found alot alot of HTML markup generated. I even tried Visual web Developer and design a simple page and then do the same thing with PHP and I found ASP.NET generates more HTML!
Now, how can ASP.NET be faster if it is generating HTML in this way!

Template generation is a very SMALL cost compared to other things that are going on in a web request. ASP.NET offers a lot more than a straight up PHP page (Session/State management etc) and injects additional markup into the response to help with this.
However, your question in general isn't really a question, if you were to take sometime to understand the difference between a web framework and a language.

ASP.NET controls generate extra markup in exchange for "easing" development

Related

Concept explanation SPA (Single Page Application)

I am working on an web application/site and I want to do it with AngularJS, ASP.NET and Typescript.
I read about the Single Page Application concept, but I still have some question about this whole concept:
Why should I prefer a SPA (Single Page Application) before multiple pages.
I also have some questions about integrating it with ASP.NET:
In ASP.NET it standard generate a nice bootstrap layout with about 3 pages at the top. So I think that it means that I need to combine all these pages to one page. But how can I get it to work together with the routing of ASP.NET. Because you will use the routing of AngularJS, and I want to keep the login from ASP.NET (Can you maybe give an example so I can see how it works).
If I got it correctly Typescript in this concept will replace the JSON webservice. Is this correct or do I got this all wrong?
If you could answer one of my questions I would be very thankful.
SPA's are a trend, they are mostly useful to move the load on your server to the clients. Only data requests will be made to the server, rendering is done on the client machine.
There are still other benefits, but I guess this is the most relevant.
As to your questions regarding integration into ASP.NET.
Building an SPA does not mean all has to fit in one page. Look at AngularJS, it will fetch views as separate requests (see templateUrl in routingprovider). That being said, you can use ASP.NET MVC and serve ASP.NET Views as Angular Templates. This allows for a neat separation of Model, View and Controller parts.
Typescript is Microsoft's JavaScript dialect. It will not replace JSON and you will probably want to use JSON to exchange data with your server. You could use XML, but that is a little bit oldfashioned (and way more bulky).
I have no experience with TypeScript so I would not consider doing that (coffee might be a better alternative), but there are also some quicks in JavaScript you need to be aware of. I would suggest to search Douglas Crockford and Javascript on Youtube. The guy has great talks that can make you a JavaScript pro.

Is the .ASPX extension ONLY associated with Web Forms?

Dumb question (maybe) I have searched online but I'm looking for somewhat a yes no type of answer. If you ever see a website with just xxx.com/xxx.aspx ... was that application created using Web Forms? Is ASPX only associated with Web Forms?
Thanks
To answer your question in yes or no (as asked), NO.
You can do that in ASP.NET MVC as well, by setting up the routing in that fashion. But I don't think anybody would do that.
On another note, if you have come across a website which is xxx.com/xxx.aspx, you can make a decently good bet that it was developed in ASP.NET WebForms.
Hope that helps!!!
Technically no. The web server software determines how to handle every request. It could be configured pretty easily to say that any requests for a file with a .aspx extension should be handled by the PHP parser, or Ruby, or whatever. Or, if using ASP.NET MVC, you could set up routes that resources that end in .aspx are still handled as MVC pages.
Of course, there aren't many reasons that someone would WANT to do that. The only reason I can think to do so would be if you're explicitly trying to make people think that a page is using a different technology than it is. And I don't see that being a common goal.

Is there a reason that cshtml isn't popular

Firstly, I have only recently tried my hand at building with razor in cshtml using Webmatrix and I found it much less time consuming than building aspx web forms. Having gotten used to it, I can now do all the things I used to do inside my aspx projects much quicker and with much less code...
Now, I've spent today looking around google etc at companies using cshtml, what they're using it for etc, but I can't find a large range of examples out there. Maybe I was just looking in the wrong place, rendering this question title incorrect, but I just had a feeling that there is a reason why companies are still using aspx over cshtml.
I'm about to start a project next month for a big client and I can't decide whether to take the step of building it this way (they need a custom blog, login area etc). Any thoughts? The only other stack thread I found of any use with regards to a debate was: Razor/CSHTML - Any Benefit over what we have?
Thanks,
Adam
A lot of it has to do with ASP (classic) has been around a lot longer and (depending the project size) a migration can incur too much cost.
There's also considerations like:
What does the current web staff know (what are they fluent in?)
What libraries (proprietary or otherwise) are already dependent on ASP (including custom controls).
How much of an SEO hit are you going to take converting (some sites can mimic classic aspx page suffixes by just changing the way the routes behaving but are in-fact using cshtml).
There isn't a compelling reason for experienced ASP.NET developers to move from Web Forms or MVC to Web Pages (Razor). As a framework, it is designed to attract those who might find Web Forms or MVC too much of a learning curve. Those coming from Classic ASP or PHP, for example.
I answer a lot of questions on the Web Pages framework over at the ASP.NET forums, and I have definitely seen an increase in the number of people trying the framework out. In terms of functionality and security, you have the whole ASP.NET framework behind you so you can do anything with Web Pages that you can do with MVC or Web Forms - a lot of it more easily.
The Web Pages framework is not designed with testability in mind, and it may be more difficult for teams to organise since a certain amount of server-logic is embedded in the same file as HTML.
If you are a lone developer and happy using Web Pages, go for it.
There been a lot of discussion about the topic. Its just opinions, right tool for the right job. Please look into the following for opinions & answers:
MVC 3 ASPX VS RAZOR View Engine
Razor vs Webforms view engine for new ASP.NET MVC 3 site
What is the difference between Razor and ASPX?
Hope this helps

Converting HTML (or Classic ASP) to ASP.NET

I was wondering if there is a way to convert and HTML template to ASP.NET? I am trying to convert a website template that was written in HTML that contains Javascript and CSS files to ASP.NET so I can connect to a SQL Server database.
I have limited coding experience with ASP.NET so any help is appreciated!
I also have access to an ASP template but it is not ASP.net unfortunately.
I'm afraid to say you are going to have to get familiar with .NET for this however I like many others had to do this back in the day... although now you have many other factors like are you going to migrate to a Webforms based ASP.NET application or an ASP.NET MVC application.
You can just put your HTML content into an .aspx page however you are going to have to learn the fundamentals of .NET and perhaps things like ADO.NET, LINQ to SQL, nHibernate to get connected to a database.
This may help, but it is rather old: http://www.asp.net/web-forms/videos/migrating/migrating-from-classic-asp-to-aspnet
Microsoft do have a lot of information to help you make this transition... http://www.asp.net/get-started
Not the best answer I realise but you will have to take on a bit of a learning curve, and who knows, you may end up loving .NET, C#, VB, etc, etc... Trust me, it won't be that hard!
There's no easy way to do what you're asking. You can save it as a .aspx page instead of .html, but you can't magically make it connect to the database without coding adjustments.
Just create a new aspx page and copy the content to the aspx file. You should not face any issue in keeping original Html tags in aspx page, but if you need to do some sort of logic on cs file then you might want to change the Html tags to asp tags. which, again should be easy.
And to connect it to database, may be you would like to connect it from cs file.

Microsoft mvc3 or ASP.NET Web pages for a new server-side scripter?

I have experience in javascript, html(Bronze certified), css(Gold certified), sql and xml(Bronze certified), and now have turned my attention towards server side scripting. I have little experience in php but have no Idea what to choose between MVC and ASP.NET Web Pages. I like all the features that ASP.NET Web Pages(Since I already new a little about server side scripting, so getting started was not that difficult and I know a few basic things.) have like, automatic form authentication among others but I seriously doubt that it can never be by-passed. Still, for safety I use my own algorithms against sql-injection and javascript codes. But, now I am confused what to learn, MVC or ASP.NET Web Pages. All the posts I searched on internet where for new programmers. Since I am not new they are no use to me. So what should I learn MVC OR ASP.NET Web Pages and why?
*English is not my native language, there may be some grammatical mistakes.
You are kind of asking what's the better option, apples or bananas. MVC is a pattern and allows you greater control over what HTML is sent to the browser whereas Web Forms has a great number of pre-made controls that do all the hard work rendering out html to the browser (but often less control of how it is rendered out)
It's also down to preferences, I personally prefer MVC as the unit testing and component nature of it give me great flexibility. Alternatively, using WebForms you can create some things quickly using drag and drop controls.
Hope that gives you a bit of useful info. I'd recommend reading up about both, and seeing which fits into your style of programming and go from there, but there's nothing stopping you learning and using both (just don't use them in the same project, lol)

Resources