how to detect asp.net webforms page? - asp.net-mvc

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" />

Related

How does IIS recognize that request is for MVC Controllers or webforms Pages?

When the Application pool receives a request, it simply passes the request to worker process (w3wp.exe) . The worker process “w3wp.exe” looks up the URL of the request in order to load the correct ISAPI extension. ISAPI extensions are the IIS way to handle requests for different resources. Once ASP.NET is installed, it installs its own ISAPI extension (aspnet_isapi.dll) and adds the mapping into IIS.
Si If that's true, my question is how does it recognize which extensions to be loaded
for that request?? MVC / Web Forms?
When and where does the IIS come to know that a request is for MVC or WebForms Application?
How framework decide which Modules should handle the request and decide to render page content or views in MVC.
hen and were the IIS come to know that request is for MVC or WebForms Application?
They are both ASP.NET applications so it doesn't need to recognize that. The aspnet_isapi.dll is perfectly capable of serving both types of applications (which are actually a single type called ASP.NET).
ASP.NET MVC is just a custom handler added to the ASP.NET pipeline.
That all is about the standard IHttpModule and IHttpHandler infrastructure. See complete description here Routing with ASP.NET Web Forms and here How ASP.NET MVC Routing Works and its Impact on the Performance of Static Requests

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

Why server controls in 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.

Classic ASP integrated with ASP.NET MVC

I have a classic asp project and a teammate created a new functionality, but it's in asp.net mvc. I also know how to work with mvc, but I never used classic asp and mvc together.
For example, is it possible, in this classic asp project, to have a link that will redirect to a mvc page on the same project?
Thanks!!
Yes, you can have a link point to any other page you'd like regardless of technology. Likewise for a redirect. To redirect in classic ASP, use Response.Redirect
Absolutely, the pages (and that term is used lightly in the MVC side of things) can link between each other without any problems. Now, any built-in authentication or session management or anything like that will be considerably more challenging, but if all the sites need to do is link to each other then they can do this like any other two websites. The ASP pages can host manually-crafted (vs. HtmlHelper-crafted) links to the MVC actions, and can host forms that post values to the MVC actions (provided the field names line up properly).
There's nothing inherently special about the MVC actions. They're just handling HTTP GET/POST requests like anything else.

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