ASP.NET 4.5 and ASP.NET Core 1 Hosting BLOG

Tutorial and Articles about ASP.NET 4.0 and the latest ASP.NET 4.5 Hosting

ASP.NET 4.5 Hosting - ASPHostPortal :: Unobtrusive Validation with ASP.NET 4.5

clock March 27, 2012 06:20 by author Jervis

ASP.NET 4.5 has been improved and latest version ASP.NET. It includes an array of new and modified features. Today we’ll discuss one new feature Unobtrusive Validation that is introduced with ASP.NET 4.5 .

So what is Unobtrusive Validation?

In a normal validation scenario,when we use a validator to validate any any control and use Client side validation, some JavaScript is generated and rendered as HTML. Also some supportive JavaScript files is also get loaded by the browser for the validation.


Now with feature Unobtrusive Validation, inline JavaScript is not generated and rendered to handle the Client Side validation. Instead of this it uses HTML5 data-* attributes for all these validation.

So now lets see a normal scenario. I have taken textbox and applied two ASP.NET validators on it. One is RequiredFieldValidator and RangeValidator that allows to enter the value between 100 and 1000. Let’s see the aspx code.



Now Lets run the application and see the generated the HTML. Now if you look at the View Source of the page



To handle these validation, it generates the lots of JavaScript code on the page. It is



Now I have made the same application with Visual Studio 2011 Developer Preview. By default Unobtrusive Validation is enabled here. So lets see the generated HTML



Now if you see the above generated HTML, there are few data-* attributes are rendered. And these hold all the required information of the validator. And there is no inline JavaScript code generated. This reduces the significant amount of page size because here inline JavaScript code is not generated and this also makes the rendered HTML neat and clean.


So let’s see how asp.net 4.5 allows to configure the Unobtrusive Validation. There is one new property UnobtrusiveValidationMode got added, which can be assigned two values

-
None : means UnobtrusiveValidation is set to off
-
WebForms : means UnobtrusiveValidation is enabled

This property can be configured at three places in application. These are

1. First it can be set at application level in config file. We need to add it in the <appSettings> element.

<
add name="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />

As I discussed it is by default enabled in asp.net. The above key by default added in web.config. So if you want to disable it then change the above as

<add name="ValidationSettings:UnobtrusiveValidationMode" value="None" />

2. We can also set it at Application_Start method in Global.asaxfile as

void Application_Start(object sender, EventArgs e)
{
   //Enabling UnobtrusiveValidation application wide
   ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.WebForms;
}

3. We can also set it at page level by setting the property of Page Class as

Page.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.WebForms;

 



ASP.NET 4 Hosting - ASPHostPortal :: Few Important Tips that You Should Know While Using ASP.NET Session

clock March 6, 2012 07:33 by author Jervis

While working with ASP.NET web application you must be familiar with one of most important state management technique “Session”.

ASP.NET Session State is on by default, hence you are paying for memory even if you don’t use it. There are several ways to optimize it.


Tip #1
: Not using Session State at all ? Then turn it off completely in web.config



Tip #2
: Session is only required for few pages not all over the application



then enable it for a specific page where you required the session




Tip #3
: If you are using Session for Reading Purpose, use Session State as “ReadOnly”

If you are a beginner, you must be wondering what is EnableSessionState=”Readonly” . Well, if you look at your web application, not all the pages using Session or some of the pages is using session data for reading purpose. If there is no write operation happaning on session, then it’s always better to use session State is “
ReadOnly



The session request pass through different httpModule with in HTTPPipeline. Know more details on how session state ReadOnly works , please read the article
Read Only Session State in ASP.NET.

You can also set ReadOnly SessionState in web.config as well




Tip #4
: Programmatically Change Session State Behavior when required (ASP.NET 4.0)

We can enable or disabled session state either in web.config or using @Page directive’s EnableSessionState attributes. But there was no provision to change the session state at runtime till date in ASP.NET. But using ASP.NET 4.0, we can change the session state programmatically . The .NET 4.0 framework adds a new method SetSessionStateBehavior to the HttpContext class for ASP.NET. This method required SessionStatebehavior value to set the current session mode. To call SetSessionStateBehavior simply create a new HttpModule by Implementing IHttModule and hook the BeginRequest event. Most important you can only use the SetSessionStateBehavior until the AcquireRequestState event is fired, because
AcquireRequestState Occurs when ASP.NET acquires the current state that is associated with the current request

While calling SetSessionStatebehavior, You can pass the following values as SessionStatebehavior :


-
Default: This is default setting which means everything works as before
- Disabled: Turned of Session Sate for Current Request.
- ReadOnly: Read only access to Session State;
- Required: Enabled session state for both Read and Write Access



Tip #5
: Compress Session Data while using OutProc Session mode based on Requirements (AP.NET 4.0)

ASP.NET 4.0 comes with a new option for compressing the Session data with Out Process Session mode. To enabling this functionality we need to add “
compressionEnabled=”true” attribute with the SessionMode in web.config.



When Compression mode is enabled is web.config, ASP.NET compress the serialized session data and passed it to session storage and during retrieval same deserialization and decompression happens in server side.
ASP.NET 4.0 used System.IO.Compression.GZStream class to compress the session mode.



Tip#6
: Use HttpContext.Current.Items for very short term storage instead of Session

You can use HttpContext.Current.Items for very short term storage. By Short term storage means, this data is valid for a single HTTP Request. There are many confusion around regarding storing data in HttpContext.Current.Items and storing data in Session variable. Items collections of HttpContext is and IDictionary key-value collections and that are shared across a single HTTPRequest. Yes, HttpContext.Current.Items valid for a single HTTPRequest.




Hope the above tips helps you.


Reasons why you must trust ASPHostPortal.com


Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what
ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:


-
DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.

- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.

- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.

- Data Center

ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.

- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.

- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.

- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.





Cheap ASP.NET 4.5 Hosting

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions


Author Link


 

Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Tag cloud

Sign in