what is single page application? [closed] - single-page-application

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
what is SPA( single page application ) ?
i'm use to react by 'create-react-app'
that is SPA ?

The simplest answer is an SPA or Single Page Application is a web app that loads a single HTML page and all the necessary assets (such as JavaScript and CSS) required for the application to run. It then uses dynamic techniques (AJAX) to update just parts of that page, instead of making a round trip to the server to create new pages.
A benefit is that you only transfer the minimum amount of data needed to make the update changes after the main page has been loaded. The main page loads all the content (js, css, etc) that the SPA needs to run so the initial page load can take longer, but after that it is very fast.
Popular ways to handle the dynamic content aspect is with frameworks or libraries like Angular or React that handle a lot of the frontend heavy lifting.
Yes, 'create-react-app' is a tool for creating a React SPA.

Not sure if I'm understanding your question correctly but...
A single page application is a way of using React that uses various 'views' instead of different pages. This is advantageous because it prevents using page redirects and page reloads which makes page navigation simple and efficient.
'create-react-app' can be used to create a SPA or a non-SPA depending on how your organize your code.

Related

ASP.NET MVC - Diffrent requirements than Classic MVC Project [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm coming from recenelty working on ASP.NET WebForms, and other Web Development frameworks .
Lately i wanted to get into the ASP.NET MVC. I read a Pro book and have some missing link that i can't understand .
How can you use MVC when many cases doesn't fit it exactly . What do i mean ?
In WebForms for example, you want to build a page, that has all kind of elements, that has nothing to do for your 'real' model. For example, just use a page to show a small chat, or some kind of ad, and some more kind of controllers that doesn't represent a data in your DB.
In MVC as i understand, the whole concept is to build pages with specific relation to their Model, and then it everything flows from there .
So for a store (most of MVC projects examples) it fits greats, some product, cart ...
My question is, how can you use MVC when you have all kind of pages that doesn't require a specific model use ? does that lose the whole point of using ASP.NET MVC ?
For most of what you're talking about there's child actions (MVC 5 and previous) or view components (MVC 6). For example, you can create a child action/view component that renders the chat control, and then you merely call this in your view/layout, and your view still just worries about the actual model its dealing with.
You can also utilize partials to render portions of mostly static HTML. If that chat control, for example, was just HTML/JavaScript, you could just include it in a partial and then call that in your view/layout. The main difference between a child action/view component and partial in this context is just whether or not you need to get and pass some stuff to the view server-side first. In effect, if your control needs a model of it's own, use a child action/view component, other wise, a partial can suffice.
You can also extend HtmlHelper to add "controls". This is useful where there's some server-side processing that needs to be done, but it doesn't require things like hitting a database, that should be handled by your controller. Think of it has kind of a midway between a child action/view component and a partial.
Finally, although the confusion is understandable, due to the tight integration between Entity Framework and MVC, the two are actually totally interchangeable. In other words your view's "model", doesn't need to be involved with a database at all. The model is just a class instance, and that can come from anywhere, be it a database, a web service, or just statically instantiated in the action.

What is the standard way of having constant content (headers, footers, sidebars) across a website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've just started web programming, but I can't find anything about how to define an html element (the best example is probably a header, like the one at the top of stackoverflow) in one file, and use it in every part of your website.
I've read something about frames, but they're deprecated; using JQuery to dynamically load content, but that would look shabby as JQuery only runs after the rest of the document has loaded; and some sites even seem to have their headers actually written out on each page, which seems like a waste of time.
What should I be doing in this case?
Php include may help you (link below)
PHP Include Files
Your code would look something like this:
<html>
<body>
<?php include 'header.php'; ?>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
</body>
</html>
Usually you have the server generate the response page on the fly and append the headers at response time using something like JSP or PHP. You can still use frames if you really want. You can also use JavaScript to pull in content on the page as well. However, this is not exactly good practice because if the user has JavaScript disabled, they will see no header. The server side appending is more accepted because it doesn't depend on what the client has enabled.
This is usually done on the server either with Server Side Includes in Apache (not requiring use of any server side language) or with the server side programming language of your choice - usually either using the concepts of page templates, sections, partials or includes (or a combination thereof).
PHP has the Include function, which has already been mentioned, ASP.NET web forms have Master Pages and User Controls, and ASP.NET MVC has layouts and partials. I imagine Ruby on Rails, Java Server Pages and any other server side frameworks will have similar constructs for common layout templates and shared content between pages.
The point is that there are at least as many methods of constructing pages with shared or common elements as there are frameworks for building pages - but no method involves "just" HTML.
Find the right one for you.

MVC: Is it a good idea to split CSS files by view? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
SO I have a big ASP.NET MVC Razor application that has a large Site.css with over 7000 lines of code, we have been discussing splitting that file into multiple files depending on Views.
For example with have the following views:
About Folder
Index.cshtml
Detail.cshtml
Contact Folder
Index.cshtml
Detail.cshtml
Support Folder
Index.cshtml
Detail.cshtml
and so on...
What we are considering is creating a Common.css file that will be added to the Layout.cshtml
And for each Views folder create a css file specific to those views, is it good practie to do this? Is is it a good idea?
I would keep everything in one css file (especially in production) because it requires only one request to get everything and the browser will cache it for future requests. You can make an exception for views that use excessive css (big 'file' size) and not requested frequently (you can track your visitors browse behaviour and optimize the css loading depending on that). For example you can consider splitting the css for a page that users/visitors only request once or not very often.
However I think it is a good idea to split the css files in development. This will keep things conveniently arranged and easy to maintain. Once you've ready with development you can merge the css files and minify them to decrease filesize. you don't have to do this manually. I'm not an ASP.net'er but I'm sure there are libraries out there that do exactly that. Also you could easily write a css merger by yourself. In the end it's just getting the content of all css files and merge them in one file (in the right order). This file can then be passed to a css minifier like http://code.google.com/p/reducisaurus/
An other option could be to embed the correct css in your html view files between style tags. This way you can separate your css without increasing the number of requests. In fact it will decrease the number of requests by minimum one. However this is not a good idea for dynamic pages as the css will always be a part of the http response (so no caching here, unless its a static page that has not been changed)
EDIT
So to conclude, I would go for a good library to handle your css. Preferably a library that supports less css as this will keep your css even more organised and a lot easier to maintain. With lessCSS you can import css files, nest classes, define variables, do other logic, etc. Great for developement! In production you simply use the compiled css.
for asp.net you could use:
http://www.dotlesscss.org/
for php you could use:
http://leafo.net/lessphp/

When to use client-side or server-side? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I just finished an intro to web dev course in my CS program and came away wondering something simple. When should you use JavaScript (client-side) instead of server-side (we used PHP but anything applies) code? Vice-versa as well.
There is no recipe for deciding that. A few notes:
security and validation should always be present at the server side (sometimes duplicated in the client).
the client-side should contain only UI-logic. No business logic.
logically, everything that accesses a database should be on the server.
Of course, if your application is a RIA (rich internet app), then you can have logic on the client. So it all depends.
Javascript should be only used to manipulate the UI of the page. You can also do certain validations using it, however, there must be corresponding validation on the server-side. For doing any data manipulation, applying business logic, etc you should always use server side code.
Here are some cases where you will use client-side code:
Changing the look (UI) of the page e.g. dynamically show/hide some
elements
Validate user inputs (this should also be done on server side)
Cases where to use server-side code:
Validation of user inputs (should always be done on server side irrespective of whether done on client side or not.)
User authentication
Business logic (deciding what to show to which users, calculations)
Database access
Imho i would say, use server-side if you can. All client-side code can be manipulated. Or maybe will not run cause the browser dont support it.

Is ASP.Net 2.0/Ajax toolkit the right technology for implementing a SEO friendly website [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
As I understand it, just URL re-writing is not the only thing one needs to do for making a website SEO friendly. You also needs to maximize the use of div (instead of tables), reduce javascripts, flashes and have a clean HTML.
I need to know how can this be achieved when one used a ASP.Net control. ASP.Net send loads of stuff to the screen which in technologies like PHP can be delivered using much cleaner code.
Can anybody tell me is there a way to force ASP.Net to render cleaner code and work with divs instead of table when one used datagridview.
Also I would appreciate if one can post the suggestions for making a existing website SEO friendly which was coded in ASP.Net C# 2.0
Making your site's pages "SEO friendly" is really about ensuring that search engines (Google), can understand the content on the on the pages. Using "semantic" html markup can go a long way to help the search engines.
ASP.NET doesn't so much make it hard to do semantic markup as it does make it easy NOT to.
Wrapping a sub-heading in an <h2> tag and styling the <h2> helps the search engine understand that a particular string of text has more weight than other text on the page. ASP.NET makes in easy to fall into the trap of just using a Label server control and applying styling to it to make it look like a heading.
GridView data controls render tables. If you repeating data would be better understood with more semantic markup, consider using a Repeater control or a Listview control if you need to support paging etc.
Step 1 to SEO optimization is understanding semantic markup. Then you can find the appropriate ASP.NET controls to achieve your optimized SEO output.
Server controls have been the main selling point for ASP.NET WebForms. It has allowed developers to quickly put up pages without thinking of HTTP, HTML, CSS, JavaScript, SEO or anything. Exactly this kind of knowledge you will need to consistently create quality markup that is SEO-friendly.
If you absolutely wish to stay with WebForms, you need to look at what output the controls you use render. If you don't like it then you may have to redefine their rendering algorithms or better create your own controls.
Also get some url rewriting module (or use the one included in .NET 3.5 SP1 - the one used by ASP.NET MVC framework) and define good-looking self-describing urls for your existing pages. Also take advantage of header tags (H1...H6), search engines look at them to see what the page says it is about.
I wouldn't worry about divs vs. tables and validation, this is not clear of how relevant this is for the SEO, there are too many widely different opinions on these matters with proofs to support each point of view. What does matter, is the content. As they say, content is the king.
What I would pay attention to is the view state that ASP.NET injects into pages. It is widely known that the close to the beginning of the page the content is, the better for search engines. ASP.NET steals the beginning of a page by putting there an often huge block of serialized view state (under circumstances can reach megabytes). Try to turn off view state for your pages if you can (if your server logic can be adapted to stateless operation). This will be a very important step.

Resources