August 26, 2011 07:18 by
Scott
Introduction
Transparent Data Encryption is a new feature in SQL Server 2008. The TDE feature provides real time encryption of both data and log files. Encryption basically working in the following way; initially the data is encrypted before it’s being written to the disk and it is decrypted before it is being read from the disk. When you are using the Transparent Data Encryption feature of SQL Server 2008 the encryption is performed by the SQL Server 2008 Database Engine and the SQL Server clients will not be aware of this change. However, before implementing this feature in Production environment I would request you to validate the solution completely in the Test Environment.
To enable Transparent Data Encryption Feature of SQL Server 2008 on a database, the DBA needs to perform the below mentioned four steps as described in Books Online:-
1. Create a master key
2. Create or obtain a certificate protected by the master key
3. Create a database encryption key and protect it by the certificate
4. Set the database to use encryption
Create a Master Key
The initial step will be to identify if there is any Master Key already created in the Instance of SQL Server 2008 where you want to implement this feature. You can verify the same by executing the below mentioned TSQL code.
USE master
GO
SELECT * FROM sys.symmetric_keys WHERE name LIKE '%MS_DatabaseMasterKey%'
GO
If there are no records found, then it means there was no predefined Master Key on the SQL Server 2008 Instance. To create a Master Key, you can execute the below mentioned TSQL code.
USE master
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'pass@word1'
GO
Create or obtain a certificate protected by the Master Key
Once Master Key is created then the next step will be to Create or obtain a certificate protected by the master key. This can be achieved by executing the below mentioned TSQL code.
Use master
GO
CREATE CERTIFICATE TDECertificate WITH SUBJECT = 'SQL Server TDE Certificate'
GO
/* Verify Certificate */
SELECT * FROM sys.certificates where [name] = 'TDECertificate'
GO
Next step will be to create a new database. Once the database is created you can create a database encryption key and protect it by the certificate by executing the below mentioned TSQL code.
Create a database encryption key and protect it by the certificate
Use master
GO
CREATE DATABASE TryEncryption
GO
Use TryEncryption
GO
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_256
ENCRYPTION BY SERVER CERTIFICATE TDECertificate
GO
Once the Database Encryption Key is created successfully you need to take a backup of the Certificate and the Private Key by executing the below mentioned TSQL code.
BACKUP CERTIFICATE TDECertificate TO FILE = 'D:\TDE\TDECertificate.cert'
WITH PRIVATE KEY (
FILE = 'D:\TDE\EncryptPrivateKey.key',
ENCRYPTION BY PASSWORD = 'Certific@tePass@word')
GO
Set the database to use encryption
The final step will be to enable encryption on the user database by executing the below mentioned TSQL code
ALTER DATABASE TryEncryption SET ENCRYPTION ON
GO
Verify Database Encryption Status
You can verify the database encryption status by executing the below mentioned TSQL code.
SELECT
DB_NAME(database_id) AS DatabaseName
,Encryption_State AS EncryptionState
,key_algorithm AS Algorithm
,key_length AS KeyLength
FROM sys.dm_database_encryption_keys
GO
SELECT
NAME AS DatabaseName
,IS_ENCRYPTED AS IsEncrypted
FROM sys.databases where name ='TryEncryption'
GO
Advantages of Transparent Data Encryption
1. Physical Security of Database Files
2. When Transparent Database Encryption feature is used all the backups of the TDE enabled database are encrypted
Disadvantages of Transparent Data Encryption
1. As Encryption is CPU intensive and it is performed at I/O level, any server with higher I/O and higher CPU load should avoid using this feature
2. This feature is only available in Enterprise and Developer Editions of SQL Server 2008
3. TDE encrypted database cannot be attached or restored in other edition of SQL Server 2008
4. If the certificate is lost then the data will be unreadable. Hence you need to protect the certificate and master key along with the database backup files
5. If you are using FILESTREAM feature, then be informed that only FILESTREAM enabled database is encrypted and not the actual files which are residing on the servers file system will be encrypted
6. There won’t be much of a benefit if you planning to use Database Backup Compression feature of SQL Server 2008
7. As TempDB database is automatically encrypted once you have enabled encryption on any of the user databases. This resulted in slow query performance for non encrypted databases which may use TempDB
For more information you can check the following link
August 9, 2011 06:18 by
Scott
The programmers are getting this error message when there is high workload on the server. And servers are experiencing high memory pressure.
In this error theire are some additional symptoms also.
1. When connecting to server will get the error message as "Login Failed".
2. Will get disconnected from server.
3. CPU usage will be very high.
4. if running "select * from sysprocesses" SPIDs will have a waittype of 0x40 or 0x0040 and a last_waittype of RESOURCE_SEMAPHORE.
5. The System Monitor object SQLServer:Memory Manager displays a non-zero
value for Memory Grants Pending.
6. SQL Profiler displays the event "Execution Warnings" that includes
the "Wait For Memory" or the "Wait For Memory Timeout" text.
Reasons for this error is memory intensive queries are getting qued and are not getting resources before timout period. And after timout period and getting timout. By default query wait period is -1 by setting non-negative number you can improve the query wait time.
Other reasons for this errors are not properly optimised queries, memory allocation for sql server is too small.
Solutions for this error include the following.
1. Optimise the performance of queries using sql profiler.
2. Distrybution statistics should be uptodate.
3. Watch the system monitor trace to see the memory usage of sql server.
4. If you are running SQL Server 7.0, test disabling parallelism for SQL Server 7.0 by turning the max degree of parallelism configuration option off.
July 20, 2011 05:16 by
Scott
Razor Layout pages are the equivalent to MasterPages in ASP.NET Web Forms and the Web Forms View Engine within ASP.NET MVC. Just as it is possible to nest MasterPages, it is also possible to nest Razor Layout pages. This article explores the process required to achieve nesting of Layout pages using the Razor View Engine in MVC 3, or WebMatrix Web Pages sites.
You would consider using nested layout pages if you were building a corporate site for a global company, for instance, which is comprised on many divisions, each having their own look and feel. There may be a common look and feel for the header and footer of the site, but the navigation and content changes in both structure and appearance depending on which division of the company is being featured. The imaginary company that the sample site relates to has a number of divisions, one of which is Automation and another for Electronics. Each of them has their own branding which needs ot be catered for. For simplicity's sake the following walkthrough illustrates the use of Razor in a Web Pages site built using WebMatrix, but the principals are exactly the same if you are using ASP.NET MVC 3.
Step 1
Create a new site using the Empty Site template and name this Nested Layouts. Add two folders to the site – one called Content and the other called Shared. Add a new CSS file to Content and leave it with the default file name of StyleSheet.css. Add the following code to it:
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 80%;
padding: 0;
margin: 0;
}
h1{
color: #0093c0;
}
#wrapper{
background-color: #c1dfde;
padding: 10px;
width: 800px;
margin: auto;
min-height: 600px;
}
#electronics, #automation{
min-height: 400px;
}
#electronics{
background-color: #8ec1da;
width: 650px;
float: left;
}
#automation{
background-color: #ffe8d3;
}
#electronicsnav{
background-color: #fff;
min-height: 400px;
width: 150px;
float: left;
}
#automationnav{
background-color: #dedede;
}
#automation h3{
color: #997d63;
}
Step 2
Add a CSHTML file to the Shared folder and name it _MainLayout.cshtml. Change the existing code so that it looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@Page.Title</title>
<link href="@Href("~/Content/StyleSheet.css")" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header"><h1>Global Enterprises</h1></div>
<div id="nav">
<a href="Home">Home</a> |
<a href="About">About</a> |
<a href="Engineering">Engineering</a> |
<a href="Electronics">Electronics</a> |
<a href="Automation">Automation</a> |
<a href="Contact">Corporate</a> |
<a href="Contact">Contact Us</a>
</div>
@RenderBody()
</div>
</body>
</html>
Step 3
Add another CSHTML file to the Shared folder and name this one _AutomationLayout.cshtml. Replace the existing code with this:
@{
Layout = "~/Shared/_MainLayout.cshtml";
}
<div id="automationnav">
<a href="Products">Products</a> |
<a href="Services">Services</a> |
<a href="Support">Support</a> |
<a href="Team">The Team</a> |
</div>
<div id="automation">
@RenderBody()
</div>
<div id="footer">The Automation Division Footer</div>
Step 4
Now add a third CSHTML file to the Shared folder. Name it _ElectronicsLayout.cshtml, delete the existing code and add the following:
@{
Layout = "~/Shared/_MainLayout.cshtml";
}
<div id="electronicsnav">
<a href="Products">Products</a> <br />
<a href="Services">Services</a> <br />
<a href="Support">Support</a> <br />
<a href="Team">The Team</a> <br />
</div>
<div id="electronics">
@RenderBody()
</div>
<div id="footer">The Electronics Division Footer</div>
Step 5
Add a CSHTML file to the root folder. Name this one Automation.cshtml and replace the existing code with this:
@{
Layout = "~/Shared/_AutomationLayout.cshtml";
Page.Title = "Automation";
}
<h3>Automation Home Page</h3>
Step 6
Finally, add another CSHTML file to the root folder and call it Electronics.cshtml. Replace the existing code with the following:
@{
Layout = "~/Shared/_ElectronicsLayout.cshtml";
Page.Title = "Electronics";
}
<h3>Electronics Home Page</h3>
Making sure that the Electronics page is selected in the left pane, click the Run button to launch the page in your browser. Notice that the second navigation has a white background and the main area has a blue background. Click the Automation link in the top navigation. See how the colours change? The main content is a brownish-pink colour as is the secondary navigation. The heading in the main content area changes colour too. Most obviously, the Electronics navigation is displayed vertically whereas the Automation navigation is horizontal.
What defines a Layout page is a call to the RenderBody method. In this exercise you created a layout page from _MainLayout.cshtml by placing @RenderBody() in the file, and by matching that with Layout declarations in both the _AutomationLayout.cshtml and ElectronicsLayout.cshtml files. You also added calls to RenderBody in both of those files, thus turning them into layout pages. Electronics.cshtml and Automation.cshtml each contained Layout declarations pointing to their own layout page, completing the content – layout relationship. There is no limit to the number of levels to which you can nest layout pages.
The design of the pages won’t win any awards, but this sample serves to illustrate that nesting layout pages can offer a very flexible solution to certain problems.
July 13, 2011 06:14 by
Scott
With CSS (Cascading Style Sheets) you can use custom fonts on your website. Normally your visitors can only see the fonts that are already installed on their computers. So if you use a font that is not installed on your website visitor’s computer then his or her browser will show some other font that is there on the computer. That’s why when you are defining a font for an element (such as <p>) you often specify multiple fonts so that if your preferred font is not available your CSS file should use the available alternatives.
Conventional way of using custom fonts for headings and logos etc. is creating the text in a graphic editor and then using the image file. From the perspective of SEO this is not appropriate; you must use text as much as possible.
Now there is a way around in CSS that lets you use custom fonts, downloadable fonts on your website. You can download the font of your preference, let’s say cool_font.ttf, and upload it to your remote server where your blog or website is hosted.
Then from within your CSS file (or wherever you are defining your styles) you have to refer to that custom font in the following manner:
@font-face {
font-family: cool_font;
src: url('cool_font.ttf');
}
After that you can use it just like a normal CSS declaration:
p.custom_font{
font-family: cool_font; /* no .ttf */
}
This way you can use as many custom fonts as you feel like on your website.
June 23, 2011 06:03 by
Scott
Visual Studio has a cool user interface for publishing a website using the Publish Web Site dialog, accessible by selecting Build, Publish Web Site. You can use this dialog to pre-compile your website and avoid having to deploy source code.
Visual Web Developer Express doesn't offer this dialog, but because the Publish Web Site dialog is just a front-end for aspnet_compiler.exe, you can use aspnet_compiler.exe from a command prompt to accomplish the same thing if you are a VWD user. While using aspnet_compiler.exe from a command prompt gives you the same functionality, using a menu option is a lot more user-friendly and avoids possibly typos that can be frustrating.
In this post, I'm going to show you how you can add some menu options to VWD that will automate the user of aspnet_compiler. It won't give you the same flexibility and convenience you get with the full-blown Visual Studio, but it will come darn close.
Note: While I will show these steps in Visual Web Developer 2005 Express Edition, you can use the same steps for Visual Web Developer 2008 Express Edition.
To add the new menu item, I'll use the External Tools option on the Tools menu in VWD. (This menu option is also available in Visual Studio.) Using the External Tools dialog, you can add menu items that will execute external applications, and you can also control command line arguments that are passed to your external application and more.
Note: I also explain how to do this in my book, The Expression Web Developer's Guide to ASP.NET 3.5.
We'll create two menu items; one for pre-compiling an updatable application and another for a non-updatable application.
1. Launch Visual Web Developer Express.
2. Select Tools, External Tools to display the External Tools dialog.
3. In the Title box, enter Pre-&Compile (non-updatable).
4. Click the browse button next to the Command box and browse to aspnet_compiler.exe located in c:\Windows\Microsoft.NET\Framework\v2.0.50727.
5. Click Open to add the command line for aspnet_compiler.exe.
Now that you've got the correct command line for the aspnet_compiler.exe, it's time to add the arguments that will correctly pre-compile your application. This is where you'll see the true power of the External Tools dialog.
1. Type -p " in the Arguments box. (That's an opening double-quote after the p.)
2. Click the right-facing arrow next to the Arguments box and select Project Directory.
3. Add a trailing double-quote to the Arguments box.
4. Press the spacebar to add a space at the end of the existing arguments.
5. Type -v / " after the space you just entered.
6. Click the right-facing arrow next to the Arguments box and select Project Directory.
7. Type \..\CompiledApp" after the existing arguments.
At this point, the Arguments box should contain the following:
-p "$(ProjectDir)" -v / "$(ProjectDir)\..\CompiledApp"
Now check the Close on Exit checkbox and click OK to add the new command to your Tools menu.
You can create another menu item that will compile the application and allow it to be updated by creating another entry using Pre-Co&mpile (updatable) as the Title and by appending -u to the arguments.
After you complete these steps, your pre-compiled application will be saved at the same level as your application's folder. For example, if your website exists in the c:\MyWebsites\WebApplication1, the pre-compiled application will be saved to c:\MyWebsites\CompiledApp. If that folder structure doesn't suit you, you can alter the steps above for your own purposes.
June 22, 2011 05:55 by
Scott
Remote validation has finally landed in RC1 of ASP.NET MVC 3. It’s a weird area as more often than not people tend to over complicate something that is really pretty simple. Thankfully the MVC implementation is fairly straightforward by simply providing wiring allowing the jQuery Validation plugin to work it's magic. Basically there is a new Remote attribute that can be used like so.
public class Credentials
{
[Remote("Username", "Validation")]
public string Username { get; set; }
public string Password { get; set; }
}
As you can see we have attributed the Username field with a Remote attribute. The 2 parameters tell us what Action and Controller we should call to perform the validation. This does make me feel slightly uneasy as it kind of feels like you are coupling the controller to the model which doesn't sit right by me. currently sitting on the fence I'll see how it works in real life. Anyway I implemented it like so,
public class ValidationController : Controller
{ public ActionResult Username(string UserName)
{
return Json(Repository.UserExists(Username), JsonRequestBehavior.AllowGet);
}
}
And thats you - provided you have the necessary client side libraries included of course (jQuery, jQuery Validate etc). and have Client Side Validation turned on (now by default in MVC3).
Configuration
The Remote attribute offers a few nice little configuration options to make things easier. The typical ones are there such as ErrorMessage, ErrorResource etc. but there are a few specific ones as well.
Fields
There may be a case where ding the name and the value of a single form field isn’t enough to perform validation. Perhaps validation is affected by some other field/value in the form. The Remote attribute accepts a comma separated list of other fields that need to be sent up with the request using the Fields parameter
This basic example will send up the value of the EmailService input field along with the value of Username. Clean and simple.
[Remote("Username", "Validation", Fields = "EmailService")]
HttpMethod
HttpMethod simply allows us to change how the ajax request is sent e.g. via POST or GET or anything else that makes sense. So to send a remote request via POST
[Remote("Username", "Validation", HttpMethod = "POST")]
A Minor Difference
You might notice if you read the release notes for RC1 that my implementation of the controller is slightly different. The reason being that the example in the release notes is broken :-). The example looks like this
public class UsersController {
public bool UserNameAvailable(string username) {
return !MyRepository.UserNameExists(username);
}
}
However the Validate plugin expects a JSON response which is fine on the surface but returning a boolean response to the client side results in a response body of False (notice the captial F) which in turn causes a parse error when the plugin performs JSON.parse. My suggested solution is actually more inline with how most people would typically write an Ajax capable controller action anyway (though I am not happy with the JsonRequestBehaviour usage) but there are other ways but they aren’t pretty….
public class ValidationController : Controller
{
public string Username(string username)
{
return (!Repository.UserExists(Username)).ToString().ToLower();
}
}
See? Ugly and plain WRONG (but it will work).
Nice to see this feature finally landing as it can be useful in certain situations.
June 9, 2011 05:22 by
Scott
May 26, 2011 06:40 by
Scott
Recently someone asked me to check a Reporting Services report that always resulted in an Unexpected Error. The report server was configured for Sharepoint Integrated Mode
You need to notice Execution timeout of SharePoint. You can change this timeout setting in the web.config of your Sharepoint site, by default in c\:inetpub\wwwroot\wss\VirtualDirectories\80.
In this web.config you will find an XML node called “httpRuntime”. In this node you have to add an extra tag: executionTimeout=”9000″:
<httpRuntime maxRequestLength=”51200″ executionTimeout=”9000″ />
Save and close the file and do an IISReset. When you run the report again, you won’t get this error anymore.
I also checked the web.config of the Report Manager, but in Native Mode this seems to be the default:
Good luck
May 24, 2011 06:26 by
Scott
HostForLIFE.eu was established to cater to an under served market in the hosting industry; web hosting for customers who want excellent service. HostForLIFE.eu – a cheap, constant uptime, excellent customer service, quality, and also reliable hosting provider in advanced Windows and ASP.NET technology. We proudly announces the availability of the SQL 2008 R2 hosting in our entire servers environment. HostForlife customers have a choice between SQL Server 2008 and SQL 2008 R2 when creating a database from inside the HostForLife hosting control panel.
SQL Server 2008 R2 delivers several breakthrough capabilities that will enable your organization to scale database operations with confidence, improve IT and developer efficiency, and enable highly scalable and well managed Business Intelligence on a self-service basis for your users. For more information on SQL Server 2008 R2, visit the Microsoft website, http://www.microsoft.com/sqlserver/en/us/default.aspx.
Some of the capabilities that customers and partners will benefit from include:
1. PowerPivot: a managed self-service analysis solution that empowers end users to access, analyze and share data across the enterprise in an IT managed environment using Excel 2010 and SharePoint Sever 2010.
2. Master Data Services: helps IT organizations centrally manage critical data assets companywide and across diverse systems, and enables more people to securely manage master data directly, and ensure the integrity of information over time.
3. Application and Multi-server Management: helps organizations proactively manage database environments efficiently at scale through centralized visibility into resource utilization and streamlined consolidation and upgrade initiatives across the application lifecycle.
4. Report Builder 3.0: report authoring component with support for geospatial visualization. This new release provides capabilities to further increase end user productivity with enhanced wizards, more powerful visualizations, and intuitive authoring.
5. StreamInsight: a low latency complex event processing platform to help IT monitor, analyze and act on the data in motion to make more informed business decisions in near real-time.
For more information about this new product, please visit our site http://hostforlife.eu/SQL-2008-R2-European-Hosting.aspx.
About HostForLife
As a leading small to mid-sized business web hosting provider, we strive to offer the most technologically advanced hosting solutions available to our customers across the world. Security, reliability, and performance are at the core of our hosting operations to ensure each site and/or application hosted on our servers is highly secured and performs at optimum level. Unlike other web hosting companies, we do not overload our servers.