Asp.net interview question and answer free download




















User could disable script in his browser or do something else to bypass client-side validation. In this case server-side validation must require to protect our data from dirty input. IF statement.

In this way, you need to check your model property values one by one for your desired result. If model property values are unexpected, inject error messages within ModelState. IsNullOrEmpty model. IsMatch model. UserName www. It has a set of attributes and classes defined in the System.

DataAnnotations assembly. Data Annotations allow us to decorate model classes with metadata. This metadata describes a set of rules that are used to validate a property. When server side model validation fails, errors are included in the ModelState. Hence, by using ModelState. IsValid property you can verify model state. It returns true if there is no error in ModelState else returns false. This setting will be applied to application level.

We can also enable the client-side validation programmatically. For this we required to enable or disable client side validation inside a Razor code block as shown below. This option will overrides the application level settings for that specific view. CDN stands for content delivery network or content distribution network CDN which is a large distributed system of servers deployed in multiple data centers across the Internet.

The goal of a CDN is to serve the content like jQuery library and other open source libraries to end-users with high availability and high performance. It reduces the load from your application server. The most important benefit is it will be cached means if a user has visited any site which is using jQuery framework from any of these CDN and your web application is also using the same CDN for serving the jQuery then for your application, it will not request the jQuery from CDN.

Or What is jQuery Validation Unobtrusive plugin? Microsoft introduced jquery. NET Framework 4. A bundle is a logical group of files that is loaded with a single HTTP request.

All bundles are create with in BundleConfig. There are so many tools for minifying the js and css files. CSS and JS files Without Bundling and Minification Suppose you have below CSS and JS files on the layout page and run the application in chrome browser and test no of request and loading time using chrome developer tools as shown below. CSS and JS files with Bundling and Minification When you will run the above application with Bundling and Minification of css and js files and test no of request and loading time using chrome developer tools as shown below.

In this way by using bundling and minification you have reduced the total no of request, size and loading time. Optimization class offers the bundling and minification techniques that is exist within the Microsoft. Optimization dll. Using this dll you can also use this technique with ASP. Browsers cache resources based on URLs. When a web page requests a resource, the browser first checks its cache to see if there is a resource with the matched URL.

If yes, then it simply uses the cached copy instead of fetching a new one from server. But bundles automatically takes care of this problem by adding a hash code to each bundle as a query parameter to the URL as shown below. Whenever you change the content of CSS and JS files then a new has code will be generated and rendered to the page automatically.

A partial view is like as user control in ASP. NET Web forms that is used for code re-usability. Partial views helps us to reduce code duplication. Hence partial views are reusable views like as Header and Footer views. We can use partial view to display blog comments, product category, social bookmarks buttons, a dynamic ticker, calendar etc.

There are four methods for rendering a partial view in ASP. For example: In a blog to show comments of an article, we would like to use www. For example: In a blog to show category list on each and every page, we would like to use RenderAction method since the list of category is populated by the different model.

For example: In a blog to show comments of an article, we would like to use RenderPartial method since an article information with comments are already populated in the view model. For example: In a blog to show category list on each and every page, we would like to use Action method since the list of category is populated by the different model.

Areas was introduced in Asp. This is very helpful in a large web application, where all the controllers, views, and models have a single set of folders and that become difficult to manage. Each MVC area has its own folder structure which allow us to keep separate controllers, views, and models. This also helps the multiple developers to work on the same web application without interfere to one another. Child actions are useful for creating reusable widgets which could be embedded into your views.

NET MVC partial views are used to create reusable widgets and a partial can be render by an action method. Also, an action which has child attribute cannot be called independently. It always will be called within a parent view otherwise it would give error. RenderAction or Html. Action helper methods from inside of a view.

JS etc. Further you can edit or customize this auto generated code according to your need. Scaffolding consists of page templates, entity page templates, field page templates, and filter templates. These templates are called Scaffold templates and allow you to quickly build a functional data-driven Web site.

Steps to create ASP. NET MVC provides a simple way to inject your piece of code or logic either before or after an action is executed. This is achieved by decorating the controllers or actions with ASP.

An attribute or custom attribute implements the ASP. You can make your own custom filters or attributes either by implementing ASP. Typically, Filters are used to perform the following common functionalities in your ASP. Custom Authentication 2. Custom Authorization User based or Role based 3.

Error handling or logging 4. User Activity Logging 5. Data Caching 6. Data Compression www. The ASP. Action Filters - Action filters are executed before or after an action is executed. The IActionFilter interface is used to create an Action Filter which provides two methods OnActionExecuting and OnActionExecuted which will be executed before or after an action is executed respectively. Result Filters - Result filters are executed before or after generating the result for an action.

Result filters are called after the Action filters. The IResultFilter interface is used to create a Result Filter which provides two methods OnResultExecuting and OnResultExecuted which will be executed before or after generating the result for an action respectively. Exception Filters - Exception filters are executed when exception occurs during the actions execution or filters execution.

The IExceptionFilter interface is used to create an Exception Filter which provides OnException method which will be executed when exception occurs during the actions execution or filters execution. Exception filters are executed if there is an unhandled exception thrown during the execution of the ASP. All ASP. You can configure your own custom filter into your application at following three levels: 1. RegisterGlobalFilters GlobalFilters. Like ASP. You can configure both the authentications by using Web.

It can be configure by using forms element within Web. The default attribute values for forms authentication are shown below: www. The value of authentication cookie contains a string representation of the encrypted and signed FormsAuthenticationTicket object.

Now, DateTime. Empty, FormsAuthentication. Encrypt ticket ; Q When standard types of authentication do not meet your requirements, you need to modify an authentication mechanism to create a custom solution. A user context has principal which represents the identity and roles for that user.

A user is authenticated by its identity and assigned roles to a user determine about authorization or permission to access resources. You can create a custom solution by evaluating the IPrincipal and IIdentity interfaces which are bound to the HttpContext as well as the current thread.

A user will be authenticated if IsAuthenticated property returns true. For authenticating a user you can use one of the following two ways: 1. IsAuthenticated 2. IsAuthenticated ASP. This filter can be applied to an action, a controller, or even globally.

This filter is based on AuthorizeAttribute class. Contains CurrentUser. You can achieve it by using ValidateInput attribute and AllowHtml attribute. ValidateInput attribute can enable or disable input validation at the controller level or at any action method.

Since you have enable Html input for only one-two properties then how to do this. To allow Html input for a single property, you should use AllowHtml attribute. Caching is a most important aspect of high-performance web application. Caching provides a way of storing frequently accessed data and reusing that data. The OutputCache filter allow you to cache the data that is output of an action method.

By default, this attribute filter cache the data till 60 seconds. After 60 sec, ASP. If you will not defined the duration, it will cached it for by default cache duration 60 sec. Output Caching Location By default, content is cached in three locations: the web server, any proxy servers, and the user's browser. You can control the content's cached location by changing the location parameter of the OutputCache attribute to any of the following values: Any, Client,Downstream, Server, None, or ServerAndClient.

By default, the location parameter has the value Any which is appropriate for most the scenarios. But sometimes there are scenarios when you required more control over the cached data. Donut caching cache an entire web page except for one or more parts of the web page. Before Donut caching, we have Output Caching which cache the entire web page. When to use Donut caching Suppose, you have a web application in which some pages like HomePage,Tools etc.

If you want to cache all these pages for all the users by using OutputCache with VaryByParam UserID, then the entire page would be cached every time for each user with a different user name or whatever your dynamic part of the page is. This is not a good practice since there will be cached pages if there are logged in user at a time.

This small part act like as a hole in the cached content and much like a donut. Donut caching is very useful in the scenarios where most of the elements in your page are rarely changed except the few sections that dynamically change, or changed based on a request parameter. Donut Hole caching Donut Hole Caching is the inverse of Donut caching means while caching the entire page it cached only a small part of the page the donut hole. When to use Donut Hole caching Suppose, you have a web application in which ProductCategory is shown on each and every pages so it makes sense to render all of the categories just once and cache the resulting HTML by using Donut Hole Caching.

Donut Hole caching is very useful in the scenarios where most of the elements in your page are dynamic except the few sections that rarely change, or changed based on a request parameter. One of the most important features of the MVC design pattern is that it enables separation of concerns.

This is known as loose coupling, and it makes testing and maintenance of our application easier. Both should depend upon abstractions. Details should depend upon abstractions. The Dependency Inversion principle DIP helps us to develop loosely couple code by ensuring that high-level modules depend on abstractions rather than concrete implementations of lower-level modules. The Inversion of Control pattern is an implementation of this principle.

The term Inversion of Control IoC refers to a programming style where a framework or runtime, controls the program flow. Inversion of control means we are changing the control from normal way. It works on Dependency Inversion Principle. The most software developed on the. More over IoC is a generic term and it is not limited to DI. For example, suppose your Client class needs to use a Service class component, then the best you can do is to make your Client class aware of an IService interface rather than a Service class.

In this way, you can change the implementation of the Service class at any time and for how many times you want without breaking the host code. IoC is a way that provide abstraction. A way to change the control. IoC gives some ways to implement DIP. If you want to make independent higher level module from the lower level module then you have to invert the control so that low level module do not control interface and creation of object. Finally IoC gives some way to invert the control.

DI is a software design pattern that allow us to develop loosely coupled code. DI is a great way to reduce tight coupling between software components. DI also enables us to better manage future changes and other complexity in our software.

The purpose of DI is to make code maintainable. The Dependency Injection pattern uses a builder object to initialize objects and provide the required dependencies to the object means it allows you to "inject" a dependency from outside the class. DI Implementation: www. NET Web Forms? Full XML Support for easy da. Question: 4 What is a bubbled event? Question: 5 What is the Web User Control? Resides in Content Files, which must be included in project in which the controls are used. Type Your Answers Net Interview Questions Asp.

Net Interview Questions and Answers Asp. At the same time I also encourage you to become a continue reader of the blog www. But most importantly practice a lot and enjoy the technology. Fire Truck Simulator Game Download. The five requirements are Support standard system settings. Be compatible with High Contrast mode. This requirement can be met by using only the System palette for UI colors.

Provide documented keyboard access for all UI features. Key points in this requirement are shortcut keys and accessible documentation. Provide notification of the focus location. This requirement is handled primarily by the. NET Framework. Convey no information by sound alone. This requirement can be met by providing redundant means of conveying information.

Explain how to use the HelpProvider component to provide help for UI elements. Describe how to create localized versions of a form. Explain how to convert data in legacy code page formats to the Unicode format.

Explain the difference between Globalization and Localization. Explain how to use the PrintPreviewDialog control to display a preview of a printed document before it is printed. What are the different approaches to testing? Explain the waterfall approach. Explain the evolutionary approach. Free Download Asp Net 3. How does the Visual Studio. NET debugger work? What are the main windows and dialog boxes that you use to debug a Visual Studio.

NET application? What is code instrumentation? How do you implement code instrumentation? Which tool do you need to use to convert. Which tool do you need to use to compile the. What are the deployment features of the.



0コメント

  • 1000 / 1000