Friday, September 9, 2011

Describe the security authentication flow and process in ASP.NET?


When a user requests a web page, there exists a process of security too, so that every anonymous user is checked for authentication before gaining access to the webpage. The following points are followed in the sequence for authentication when a client attempts a page request:

·         A .aspx web page residing on an IIS web server is requested by an end user
·         IIS checks for the user's credentials
·         Authentication is done by IIS. If authenticated, a token is passed to the ASP.NET worker process along with the request
·         Based on the authentication token from IIS, and on the web.config settings for the requested resource, ASP.NET impersonates the end user to the request thread. For impersonation, the web.config impersonate attribute's value is checked.

What is different between WebUserControl and in WebCustomControl ?

Web user controls :- Web User Control is Easier to create and another thing is that its support is limited for users who use a visual design tool one good thing is that its contains static layout one more thing a separate copy is required for each application. 

Web custom controls:-Web Custom Control is typical to create and good for dynamic layout and another thing is it have full tool support for user and a single copy of control is required because it is placed in Global Assembly cache. 

What is main difference between GridLayout and FormLayout ?

GridLayout helps in providing absolute positioning of every control placed on the page. It is easier to develop page with absolute positioning because control can be placed any where according to our requirement. But FormLayout is little different only experience Web Developer used this one reason is it is helpful for wider range browser. If there is absolute positioning we can notice that there are number of DIV tags. But in FormLayout whole work are done through the tables.

How to start Outlook,NotePad file in AsP.NET with code ?

Here is the syntax to open outlook or notepad file in ASP.NET VB.NET Process.Start("Notepad.exe") Process.Start("msimn.exe"); C#.NET System.Diagnostics.Process.Start("msimn.exe"); System.Diagnostics.Process.Start("Notepad.exe"); 

What is cross page posting in ASP.NET2.0 ?

When we have to post data from one page to another in application we used server.transfer method but in this the URL remains the same but in cross page posting there is little different there is normal post back is done but in target page we can access values of server control in the source page.This is quite simple we have to only set the PostBackUrl property of Button,LinkButton or imagebutton which specifies the target page. 


In target page we can access the PreviousPage property. and we have to use the @PreviousPageType directive. We can access control of PreviousPage by using the findcontrol method. When we set the PostBackURL property ASP.NET framework bind the HTML and Javascript function automatically.

Explain how the ASP.NET MVC framework differs from the current ASP.NET Web Forms


  1. Web Forms is hard to test as compared to ASP.NET MVC application
  2. ASP.NET MVC requires you to specify every little bit of HTML as comared to web forms.
  3. The Separation of Concerns (SoC) is not proper in Web Forms Development. In MVC there is a clear separation between your UI and code.
  4. Web Forms was designed to abstract the Web machinery whereas ASP.NET MVC was designed with testability and DI in mind
  5. ASP.NET MVC takes you towards a better design of the code
  6. ASP.NET MVC is not EventDriven where asp.net web forms use events.
  7. ASP.NET MVC does not have third party control support.Web forms provide rich support for third party controls.
  8. In Web Forms to achieve statefulness, state of every page stored in viewstate which often rendered on client page as a hidden field.
  9. In ASP.NET MVC no viewstate is ever required to persist the state of the page.
  10. In Web Forms the post back model of ASP.NET page makes it harder for search engines to rank the page. No posback is needed in ASP.NET MVC.

What are the advantages of ASP.NET MVC?

The main advantages are as following

  1. Enables the full control over the rendered HTML.
  2. Provides clean separation of concerns (SoC).
  3. Enables Test Driven Development (TDD).
  4. Easy integration with JavaScript frameworks.
  5. Following the design of stateless nature of the web.
  6. RESTful urls that enables SEO.
  7. No ViewState and PostBack events

Difference between HTTPGet and HTTPPost methods –


The HTTPGet protocol creates a query string of the name-and-value pairs and then appends the query string to the URL of the script on the server that handles the request. Therefore, you can mark the request.
The HTTPPost protocol passes the name-and-value pairs in the body of the HTTP request message.
Length -
Since, HTTPGet request goes via URL, so it has a limitation for its length. It can’t be more than 255 characters long (though this is browser dependent, but usually the max is 255 characters only).
Whereas
No such maximum length limitation holds for the HTTPPost request for the obvious reason that it becomes a part of the body of the HTTP request and there is no size limitation for the body of an HTTP request/response.
Performance -
HTTPGet request is comparatively faster as it’s relatively simpler to create a GET request and
the time spent in the encapsulation of the HTTPPost request in the HTTP body is saved in this case. In addition, the maximum length restriction facilitates better optimization of HTTPGet implementation.
Type of Data -
HTTPGet request is sent via URL string and as we all know that URL can be text-only, so GET can carry only text data
whereas
HTTPPost has no such restriction and it can carry both text as well as binary data.
Caching/Bookmarking – again for the obvious reason that a HTTPGet request is nothing but an URL hence it can be cached as well as Bookmarked.
No such luxuries with a HTTPPost request.
FORM Default -
HTTPGet is the default method of the HTML FORM element.
To submit a FORM using POST method, we need to specify the method attribute and give it the value “HTTPPost”.

What is ASP.NET MVC?

ASP.NET MVC is a part of the ASP.NET Web application framework. It is one of the two different programming models you can use to create ASP.NET Web applications,the other being ASP.NET Web Forms.


An MVC Application is designed and implemented using the following three attributes



  • Model: The model contains the core information for an application. This includes the data and validation rules as well as data access and aggregation logic.
  • View: The view encapsulates the presentation of the application, and in ASP.NET this is typically the HTML markup.
  • Controller: The controller contains the control-flow logic. It interacts with the Model and Views to control the flow of information and execution of the application.