Why server controls in asp.net mvc? - asp.net-mvc

Considering that ASP.net MVC doesn't support PostBack or ViewState, why are server controls available when creating asp.net mvc applications?

They are available only if you are using the WebForms view engine because they come as legacy from classic WebForms. With Razor they are no longer available. Anyway, they should never be used in an ASP.NET MVC application so why care about them? If you are working with an ASP.NET MVC application think of them as something non-existent.

Related

Difference in webapi in asp.net and asp.net core

In Visual Studio I have a choice of creating an ASP.NET Core (2) and ASP.NET application. I understand the differences between the core and non-core frameworks, but it seems there is a difference in how ASP.Net MVC/webapi is handled by the two versions, specifically and focusing only on webapi I'm getting the impression:
Core can create 2 types
1. Webapi: a RESTful service, and nothing more
2. Web MVC: MVC web application using razor with webapi available
However, non-core (for want of a better word)
1. webapi: RESTful service but built on (you have to have) MVC
2. mvc: A MVC without ability to use webapi. MVC can use razor or web forms
Can someone let me know why ASP.Net MVC has been separated like this as it's really confusing, and whether future versions (I'm presuming .net core seems the more up to date) will converge in how they work (i.e. full-fat MVC will allow separation of web api).
thanks.

What's the advantage of ASP.NET Web API to ASP.NET MVC Controller?

What's the advantage of ASP.NET Web API to ASP.NET MVC Controller?
As far as I know, IIS + WebDAV conflicts with ASP.NET Web API while using "PUT" verb[1].
We can use ASP.NET MVC Controller & JsonResult, etc. to communicate with clients, which use HTTP GET+POST and no more verb to get better compatibility, so what's the advantage of ASP.NET Web API to ASP.NET MVC?
And, ASP.NET Web API should only use the desigend teens HTTP verbs. If I'd like to develop a Web API to let a robot JUMP, but JUMP is not a standard HTTP verb. So how to design the url? http://localhost/api/robot/jump ? But it is not RESTful(RESTful urls should not contain verb).
reference:
[1] http://forums.iis.net/t/1163441.aspx
If you are asking about the difference between Asp.Net application .cs files and controllers in MVC.
We can navigate to required method in MVC depending upon requirement but this is not possible in Asp.Net web.
Always, firing the page load event will not happen.
We can return partial results/Json results/Javascript results and so on.
Unlike Asp.Net life cycle, MVC has its own page life cycle.
Regards,
Pavan.G

how to detect asp.net webforms page?

if a page contains a Viewstate in the source. Does this mean the webpage is using ASP.NET WebForms or could this also be an MVC project ?
Thanks!
Source: ASP.NET MVC and Web Forms Integration
IIS needs to be able to figure out whether a given request is an
ASP.NET MVC or a Web Forms request. Once it can figure that out, IIS
can send the request to the appropriate handler and the application
behaves as you’d expect.
check these lines from that nice article.
Caution
Watch out for ViewState! Though many parts of the ASP.NET Framework
are accessible by both Web Forms and ASP.NET MVC, the most significant
piece of the Web Forms Framework that is not supported in ASP.NET MVC
at all is ViewState. Most often, ViewState is used for a Web Forms
Page to communicate with itself, so the chances of running into
ViewState issues when cross-posting between Web Forms pages and
ASP.NET MVC controllers are slim.
However, when transitioning your Web Forms application to ASP.NET MVC,
be on the lookout for any code in your Web Forms application that
expects ViewState — the ViewState data will not exist during the
course of an ASP.NET MVC request so code that depends on it will
likely break!
There is no ViewState in MVC. So if you find a ViewState element, you can be pretty sure that it's an ASP.NET WebForms page.
Although, since ViewState is just a regular hidden input element with name/id "__VIEWSTATE", there is a slight chance, that someone added such an element (in a non-ASP.NET page) with exactly that name and id:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="contents go here" />

Best practices for Silverlight usage in a ASP.NET MVC application

What are the best practices for ASP.NET MVC and Silverlight usage in a web application? To be specific which libraries/frameworks (like prism) should be used in order to make the application unit testable and develop rapid? How one should pass data to the silverlight part from asp.net mvc (binding if possible?) and vice verse (from asp.net to silverlight)?
The Entity Framework with RIA services is made precisely for this purpose.
I propose:
asp.net mvc as service layer
silverlight as client
linq2sql for datalayer
nunit for testing

Which's the best performance between Asp.net MVC controller VS. Wcf for Silverlight Application?

I found that Asp.net Mvc controller can serve both Asp.net Mvc View and Silverlight application via DynamicActionResult(It can be Simple Action Result or Json Action Result depend on request type). So, I have 3 options for creating middle-tier for Silverlight application.
Pure WCF Service Every request to WCF must be declare in interface. So, it's strongly-typed connection.
Asp.net MVC Controller It can serve both Asp.net MVC View and Silverlight application at the same time.
Using both of them I found that it's possible to doing this by using the answer in the following link. I think, It doesn't good idea for creating both of them.
WCF Service with Asp.net MVC application
Which's the best performance between WCF Service and Asp.net MVC Controller?
Thanks,
Do you have the kind of service that would benefit from caching? If so, my testing says that MVC with Output Caching turned on is very much faster than WCF.

Resources