Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

Tutorial and Articles about Windows Hosting, SQL Hosting, MVC Hosting, and Silverlight Hosting

SQL 2012 Hosting - ASPHostPortal :: SSRS with SQL Server 2012 Denali and Sharepoint 2010

clock July 27, 2012 06:20 by author Jervis

In the new SQl server 2012 Denali SSRS is integrated in SharePoint 2010 as a Service application. This has few benefits over the old SSRS

- Easy deployment of SSRS reports in SharePoint 2010 server.

- Since SSRS is an Service application and now has its own database (like any other service application database).
- Administrators can now perform all the day-to-day activities like backup\restore of SSRS applictaion database, checking uls logs using Powershell etc.
- Supports WCF and Claims based Communication, built-in Scale with load balancing, PowerShell commandlets and cross-farm report consumption.
- Alerting is a new capability that has been introduced to Denali Reporting Services. You can now setup alert rules and be alerted when report data changes occur that match a set of rules.
- Denali is using Visual Studio 2010 so new reports can be build in Visual studio 2010 and published to SharePoint

Once you have configured SSRS service application you can use various available tools to create and Publish interactive reports in SharePoint 2010. Lets look at some of these tools


Report Builder 3.0
- Report Builder 3.0 is a tool which is Integrated in Denali and is used for creating and Publishing Interactive reports to a Reporting server like SharePoint.You can quickly start building reports in Report Builder by creating and publishing report parts,shared dataset, Creating Table, Matrix, Chart wizard or using Map wizard to create aggregated data reports into the SharePoint server.

Report Builder and SharePoint 2010
- When SSRS is integrated with SharePoint “Report Builder” is available as a Content type. You can create a library and start using Report Builder as a content type in your library.

Creating a new report with Report builder Content Type
– Once you add the “Report builder” content type to your library you can simple launch the Report builder tool\wizard by New Document item menu on the Ribbon and select “Report Builder Report”.

Power View or Project Crescent
- Power View is feature of Microsoft SQL Server 2012 Denali which serves as an Add-in for Microsoft SharePoint Server 2010 Enterprise Edition to build reports with an excellent data exploration, visualization, and presentation. Project Crescent runs in the browser and is working against a BI Semantic Model (BISM). BI Semantic Model is available on the client through the Excel based Power pivot modeling tool or on the server through Analysis Services Tabular project with SQL Server Denali.

Check Out the System Requirements for Power View Here.

Lets look at some of the advantages of using this new tool -


- Power View is a thin web client that launches right in the browser from a tabular model in SharePoint Server 2010.

- In Power View you’re working with the real data.
- You can simply drag-drop various controls to Power View designer and create presentable reports in minutes.
- In Power View, you can quickly create a variety of visualizations, from tables and matrices to bubble charts and sets of small multiple charts.
- Project Crescent is optimized for design and online screen consumption and interactivity.

Now, you can get all new features in SQL 2012 Hosting with us. Click
here to visit our site.



SQL 2012 Hosting - ASPHostPortal :: New T-SQL Features in SQL Server 2012

clock July 17, 2012 09:17 by author Jervis

Paging Data

Paging is a big issue for developers as it is required for many applications but entails many performance problems. Developers have used different workarounds to support paging.

For example, assume we need to display several pages of the HumanResource.Employee object with 5 rows per page. Below is the query you need to execute this in SQL Server 2012.

DECLARE @page_index SMALLINT ,
@page_Size SMALLINT = 5,
@offset INT
SET @page_index = 2
SET @offset = ( (@page_index - 1) * @page_Size)
SELECT   BusinessEntityID,
         NationalIDNumber,
         JobTitle
FROM HumanResources.Employee
ORDER BY BusinessEntityID

OFFSET @offset ROWS
FETCH NEXT @page_Size ROWS ONLY

In this query you will note that there are two additional syntaxes added to the well-known SELECT query.

OFFSET <offset> ROWS

The number of rows to exclude from the top.

FETCH NEXT <page_size> ROWS ONLY

The number of rows to display.

So in the results you will only receive the data you need.



You must remember that ORDER BY clause is a must, you can have multiple columns for the ORDER BY clause.


SELECT SOH.SalesOrderID

       ,SOD.SalesOrderDetailID
       ,P.Name As ProductNam
       FROM
Sales.SalesOrderDetail SOD INNER JOIN Sales.SalesOrderHeader SOH

ON SOD.SalesOrderID = SOH.SalesOrderID

INNER JOIN Production.Product P ON P.ProductID = SOD.ProductID

ORDER BY SOH.SalesOrderID,SOD.SalesOrderDetailID DESC

OFFSET 100 ROWS

FETCH NEXT 25 ROWS ONLY


The query plan for this will appear as below:




As you can see, the Top operator will be introduced at an almost zero percent cost.


Lag & Lead

This is another T-SQL feature added to SQL Server 2012 addresses an issue in reporting.


Let me describe this feature with a real world example.

Below are the sales amounts for one month.



The above data was generated from the FactInternetSales table in the AdventureWorksDWDenali database. You can find the same script in the 5528EN _02_03.sql file in the code folder.


For reports you need this month’s sales and last month’s sales along with the difference between the two months.


If you were asked to write a query for this, you query would look like:


SELECT

 t1.Year,
 t1.Month,
 t1.SalesAmount as SalesAmountThisMonth,
 t2.SalesAmount as SalesAmountLastMonth,
 t1.SalesAmount - t2.SalesAmount SalesDifferent
FROM MonthlySales as t1

LEFT OUTER JOIN MonthlySales as t2

ON (t1.Year = t2.Year) AND (t1.Month = t2.Month+1)

ORDER BY Year, Month


You need to use LEFT OUTER JOIN as INNER JOIN will not give any rows for the very first month in the data set.


Obviously, there will be a either an index scan or a table scan (depending whether you have an index or

not) twice for the table which is costly.

With SQL Server 2012, the new T-SQL function LAG is introduced just to address the above scenario:


SELECT

 Year,
 Month,
 SalesAmount as SalesAmountThisMonth,
 LAG(SalesAmount, 1, NULL) OVER(ORDER BY Year, Month) as SalesAmountLastMonth,
 SalesAmount - LAG(SalesAmount, 1, 0) OVER(ORDER BY Year, Month) SalesDifferent
FROM MonthlySales


As shown in the above example, the
LAG analytical function has three parameters. The first parameter is the expression which is the column in this scenario. The second parameter is the offset, since we are looking for last month this parameter is 1. If you want the last year’s comparative month’s data to be displayed then this parameter should be 12. The third parameter is the default, in case there is no match for the previous month, default value will be displayed.

So the output of the above query will be:




So how does this new syntax compare with the pre-2012 syntax? The simple way to compare them is running both queries in one batch and check the execution plan as shown in the below image. In the batch, the first query is the old style query and second query is the one using the
LAGfunction.



Relative cost wise, the first query (old style LEFT OUTER JOIN) cost is 77% whereas the query which contains
LAG cost is 23%. These queries were analyzed for Reads and duration using the SQL Profiler.

Below are the results for both queries executed after clearing the cache.


Reads

Duration (ms)

LEFT OUTER JOIN

125

8

LAG

46

3

Obviously using LAG has a clear performance advantage. However, to achieve better performance you need to cover those columns (in the above scenario, it will be Year and Month).

You can also use the
LAG function for grouping. For example, if you want product model sales differenciated by name you could use the below query.

SELECT

 ModelName,
 Year,
 Month,
 SalesAmount as SalesAmountThisMonth,
 LAG(SalesAmount, 1, NULL) OVER(PARTITION BY ModelName ORDER BY Year, Month) as SalesAmountLastMonth,
 SalesAmount - LAG(SalesAmount, 1, 0) OVER(PARTITION BY ModelName ORDER BY Year, Month) SalesDifferent
FROM ModelNameWiseMonthlySales


And the result is:




From the above results, you will see that the Sales Amount for the previous month is taken only for the model name.


LEAD
is another new function which is similar to LAGbut instead shows the future records.

SELECT

 Year,
 Month,
 SalesAmount as SalesAmountThisMonth,
 LAG(SalesAmount, 1, NULL) OVER(ORDER BY Year, Month) as SalesAmountLastMonth,
 LEAD(SalesAmount, 1, NULL) OVER(ORDER BY Year, Month) as SalesAmountNextMonth
FROM MonthlySales


As you can see from the below screenshot, the above query will give you the previous month’s and next month’s sales values in a single query.




FIRST_VALUE & LAST_VALUE


FIRST_VALUE
will return the first value while LAST_VALUE will return the last in an ordered set of values in SQL Server 2012.

Take for example, the below query.


SELECT

d.LastName,

d.GroupName,

e.JobTitle,

e.HireDate,

FIRST_VALUE(e.HireDate) OVER (PARTITION BY d.GroupName  ORDER BY e.JobTitle)
AS FirstValue,

LAST_VALUE(e.HireDate) OVER (PARTITION BY d.GroupName  ORDER BY e.JobTitle)
AS LastValue

 FROM HumanResources.Employee e
INNER JOIN HumanResources.vEmployeeDepartmentHistory d

ON e.BusinessEntityID = d.BusinessEntityID


This query will join the HumanResources.Employee table and the HumanResources.vEmployeeDepartmentHistory view together via BusinessEntityID. You can see that LastName, JobTitle, GroupName and Hiredate are selected from either the table or the view.


If you closely look at the
LAST_VALUE and the FIRST_VALUE function, you will observe that the Partition column and the order by column (Which are HireDate and GroupName respectively) are the same.

FIRST_VALUE
will give you the first value of the hiredate for each group when it orders by job title.

The results are given below:




CUME_DIST / PERCENT_RANK

CUME_DIST
and PERCENT_RANK can be used to calculate the relative rank of a row within a group of rows in SQL Server 2012.

Use PERCENT_RANK to evaluate the relative standing of a value within a query result set or partition.

PERCENT_RANK = (RANK() – 1) /

(TotalRows – 1)


CUME_DIST calculates the relative position of a specified value in a group of values.


The below example displays the Rank,
PERCENT_RANK and CUME_DIST

SELECT SalesOrderID,
 RANK() OVER(ORDER BY SalesOrderID) RANK,
 PERCENT_RANK() OVER(ORDER BY SalesOrderID) AS PERCENT_RANK,
 CUME_DIST() OVER(ORDER BY SalesOrderID) AS CUME_DIST
 FROM Sales.SalesOrderDetail
 WHERE SalesOrderID IN (75121,75122,75123 )

The result for the above query is shown below:



IIF

I’m not sure why the
IIF function which is a very simple function has not been included in previous versions of SQL Server. IIF is similar to the CASE function but it is optimized for evaluating two values. For example:

SELECT PersonType,

IIF(PersonType = 'EM','Employee','Other') PersonType

FROM Person.Person


The above query will return an Employee for the rows where PersonType equals EM and Other if not.


CHOOSE

This new simple feature is useful for extracting data elements from a data array:


DECLARE @MonthNumber int = 5
SELECT CHOOSE(@MonthNumber, 'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC') AS Month

The above will return the 5th element from the above array which is MAY.

TRY_CONVERT

The CONVERT function was used for earlier versions of SQL Server.

Let us say, we have a table with dates.

INSERT INTO MyData

(MyDate)

VALUES

('2011-01-01'),

('2012-12-31'),

('2012-02-29'),

('2011-02-29')


Note that 2011-02-29 is an invalid date. You could use
CONVERT function to convert varchar to the date data type:

SELECT CONVERT(date,MyDate) Mydate

FROM MyData

However, will return an error since you have an error in the last row. In SQL Server 2012, you can use the new feature,
TRY_CONVERT.

SELECT TRY_CONVERT(date,MyDate) Mydate

FROM MyData

TRY_CONVERT will return all the correct rows and invalid row will return null value. Main important thing is this won’t trigger an exception which will fail.

Apart from this you can use TRY_CONVERT function to retrieve only the error records.

SELECT MyDate

FROM MyData

WHERE TRY_CONVERT(date,Mydate) IS NULL


Instead of throwing an error TRY_CONVERT returns a NULL value and you can then more easily handle this in your code.


CONCAT

CONCAT is a significant addition for DQL Server developers.


If you have table with Title, FirstName, MiddleName, LastName columns and you may need to combine these columns and display them as a single column as shown below.

SELECT Title,FirstName,MiddleName, LastName ,
Title + ' '+ FirstName+ ' '+MiddleName+ ' '+LastName FullName
FROM Person.Person

Result are shown below:



However, except for three records and all the rows are null. That is because when a NULL value is added to a value the result is NULL.


The solution is to utilize the ISNULL function.


SELECT Title,FirstName,MiddleName, LastName ,

ISNULL(Title,'') + ' '+ FirstName+ ' '+ ISNULL(MiddleName, '' )+ ' '+LastName FullName

FROM Person.Person


However, this might be a tedious task if you have numerous columns to combine. In SQL Server 2012, you have a new function CONCAT which returns a string that is the result of concatenating two or more string values.


SELECT Title,FirstName,MiddleName, LastName ,

CONCAT(Title, ' ',FirstName, ' ',MiddleName, ' ',LastName) FullName

FROM Person.Person

From the below results you can see the null issue is eliminated in the FullName column.




Note that the
CONCAT function has no performance impact compared with the old-style syntax.

PARSE & TRY_PARSE

PARSE is somewhat similar to CONVERT in that it can convert one value to another specified value, however it should only be used for converting from a string to a date/time or number type. Note that since this is a CLR function it may have some performance impact.


SELECT PARSE('11/28/2011' AS datetime)
GO
SELECT PARSE('Monday, 28 November 2011' AS datetime USING 'en-US')
GO

As with TRY_CONVERT there is a function called TRY_PARSE to facilitate errors – ie it returns a NULL instead of throwing an error.

Date Time Functions

There are quite few date time functions introduced as shown in the below code. All the below functions will take parameters and generate datetime values from (except for DATEPART which outputs a part of a date as an integer).

SELECT
  DATEFROMPARTS(2012, 01, 31)   AS DATE_FROM_PARTS,
  DATETIME2FROMPARTS(2012, 01, 31, 15, 24, 5, 2, 7)  AS DATETIME2_FROM_PARTS,
  DATETIMEFROMPARTS(2012, 01, 31, 15, 30, 5, 997)   AS DATETIME_FROM_PARTS,
  DATETIMEOFFSETFROMPARTS(2012, 01, 31, 15, 30, 5, 1, -8, 0, 7)   AS DATETIMEOFFSET_FROM_PARTS,
  SMALLDATETIMEFROMPARTS(2012, 01, 31, 15, 30)   AS SMALLDATETIME_FROM_PARTS,
  TIMEFROMPARTS(15, 30, 5, 1, 7)    AS TIME_FROM_PARTS

All above functions will add different date parts and outputs will be given as a datetime.



EOMonth


In many human resource applications, you are required to get last date of the month. In previous versions of SQL Server, you might need to use following syntax.


SELECT

CAST(DATEADD(d,-1,(DATEADD(mm,DATEDIFF(m,0,GETDATE())+1,0)))AS DATE)

In SQL Server 2012 you can simply use EOMONTH to perform this:


SELECT EOMONTH(GETDATE())

There will not be any performance gain or loss since this function and the old-style function will both have same performance impact.



IIS 7.0 Hosting - ASPHostPortal :: How to Redirect HTTP to HTTPS

clock June 26, 2012 06:08 by author Jervis

Redirecting all traffic from HTTP to HTTPS in IIS7 will make sure your users always access the site securely. There are many different ways to set up an IIS7 Redirect from HTTP to HTTPS and some are better than others. The ideal HTTP to HTTPS redirect would do the following:

- Gently redirect users to HTTPS so users don’t have to type in “https” in the URL

- Redirect users to the specific page that they were going to go to on HTTP (page.htm)
- Save any variables passed in the query string (?page=2)
- Work in all browsers
- Transfer PageRank to the redirected page by using a 301 redirect, maintaining SEO
- Allow specific parts of a site to force SSL but allow HTTP on other parts of the site
- Redirect users from mydomain.com to www.mydomain.com

For me, this is two best method to redirecting HTTP to HTTPS in IIS 7.


Method 1 – Using Microsoft URL Rewrite Module

For this method of redirecting from HTTP to HTTPS, you will need to do the following;


1. Install the Microsoft URL Rewrite Module

2. Install your SSL certificate in IIS 7 and bind it to your website

3. Make sure Require SSL is NOT checked under SSL Settings for your website (uncheck the boxes that are checked in this screenshot)



4. Copy and paste the following code between the <rules> and </rules> tags in your web.config file in your website root directory.


<rule name="HTTP to HTTPS redirect" stopProcessing="true">

   <match url="(.*)" />
     <conditions>
       <add input="{HTTPS}" pattern="off" ignoreCase="true" />
     </conditions>
   <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
 </rule>

5. Test the site by going to http://www.yoursite.com and making sure it redirects


Method 2 – Setting up a Custom Error Page


The second method of setting up an IIS7 redirect HTTP to HTTPS is to Require SSL on the site or part of the site and set up a custom 403.4 error page. To do this, just following these steps:


1. Install your SSL certificate in IIS 7 and bind it to your website


2. In IIS, click on the site name, and go to the SSL Settings section




3. Check
Require SSL and Require 128-bit SSL and click Apply.



4. After doing this, you will normally get this error:




5. Create a new text file and paste the following into it:


<html>

 <head><title>Redirecting...</title></head>
 <script language="JavaScript">
 function redirectHttpToHttps()
 {
     var httpURL= window.location.hostname + window.location.pathname + window.location.search;
     var httpsURL= "https://" + httpURL;
     window.location = httpsURL;
 }
 redirectHttpToHttps();
 </script>
 <body>
 </body>
 </html>

6. Save the file as
redirectToHttps.htm in your C:\Inetpub directory

7. Back in IIS, click on the site name and double-click the
Error Pages option



8. Click
Add… and enter 403.4 as the Status code. Browse for the redirectToHttps.htm file you just created and click OK



9. Select the error code and press
Edit Feature Settings



10. Click the
Custom error pages option and again browse for the redirectToHttps.htm file



11. Test the site by going to http://www.yoursite.com and making sure it redirects


A caveat of using a custom error page to do an IIS7 redirect from HTTP to HTTPS is that the web browser must have JavaScript enabled for the redirection to work.


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.



Silverlight 5 Hosting - ASPHostPortal :: How to Debug XAML Bindings in Silverlight 5

clock June 13, 2012 08:55 by author Jervis

The example demonstrated here implements basic XAML data binding. Below we have specified both the scenario when binding is correct and incorrect.

In below example we have given a simple binding for DataGrid.


When Binding is Correct:




Now you can apply a breakpoint to the binding syntax. Once the break point is applied, it hits the breakpoint whenever push and pull is triggered for that control. The below image shows the breakpoint applied within XAML




The XAML editor will not allow you to set breakpoint anywhere else other than Binding syntax.

Once Breakpoint is set, start debugging and wait for the compiler to hit the breakpoint.



You can find the debug information from Local tab.




The information shows up a BindingState object holding complete binding context information of the control. As in the above image, the BindingState value is UpdatingTarget so this way it shows that the binding is pushing data to control.


Going through the debugging information, it shows the complete picture on the nature of data and binding




Now another thing to know is, on TwoWay binding scenario once you change the data, The breakpoint again gets a hit as the binding source is getting updated. And the debug information shows the Binding state as Updating Source status. The breakpoint again gets a hit as the binding source is getting updated. And the debug information shows the Binding state as Updating Source status.




When Binding is Incorrect:


When binding is incorrect you will get the error while debugging the binding.




This will help you to find the incorrect bindings in your XAML.

Hope this helps you to get acquainted with the new feature of Silverlight 5

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.



SQL 2012 Hosting - ASPHostPortal :: Restore Database Enhancements in SQL 2012

clock June 11, 2012 08:46 by author Jervis

In SQL 2012, Microsoft has introduced some nice restore database enhancements.
The major enhancements are:


1. Point-in-time restore has now a visual timeline that allows you to quickly select the target time and perform your restore.

2. Page Restore worked already in SQL 2008 (R2) and SQL 2005 but it has now a nice user interface. It allows you to check your database for corrupt pages and restore them from a good backup file.


In this blog, I’ll give you an overview how to use these 2 new features.

Point-in-time restore

In the Object Browser of your SSMS, right click on Databases and select “Restore Database”

In this example, I will perform a restore of the Adventureworks2008R2 database. I selected Device to get my backup files. Just press the […] button



In the locate backup file window, I select all the backup files (Full backups and Transaction Logs) that have been made. To create the backups, I just created a simple Maintenance Plan.

Click on OK.



Now all the backup sets are in the list (this is not new…). As you can see, there is a new button called “Timeline”. Click on it to open the timeline interface.




Now, you can choose to restore to the last backup taken or choose a specific date and time. With the timeline, you can scroll to the restore time that you want. On the timeline you can also see what types of backups will be used to perform the restore. Once you selected the correct time, just press the OK button.




Now press OK again, to start your restore. A restore plan is automatically generated and your database is restored till the requested time.






Page Restore

To perform a page restore,I first need to have a corrupt database and you also need to have a GOOD backup file,which means, without the corrupt page.
As you can see below, I did a DBCC checkdb and my database is indeed corrupt.



Let’s fix this database!

Right click on your DB, select Tasks – Restore – Page



In the Restore Page window, the database is selected and the Pages grid is automatically showing the damaged pages. You can also run DBCC CHECKDB, by clicking on the button “Check Database Pages”, to find out if there are more damaged pages in the database. You also need to set the location for the Tail-Log backup file. The Backup sets grid shows you all the backups that can be used to fix your pages.






Just click on the OK button to start the page restore




When I check my database again with DBCC CHECKDB I see that the damaged page has been fixed




I think those 2 new features will make the life of the DBA just a little bit easier


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.

 



Silverlight 5 Hosting - ASPHostPortal :: Playing HTML5 Video with fall back for IE8/IE7 and earlier versions of other browsers using Silverlight

clock May 30, 2012 08:12 by author Jervis

One of the popular HTML5 tags is the video tag. The ability to play videos without depending on a plugin is something that excites web developers to a great extent and no wonder you end up seeing video demos in all HTML5 conferences.

Now, coming to HTML5 Video, the tag itself is simply <video id=”ID” src=”FILENAME.mp4/ogv/webm” > in the simplest form. This also means that the video needs to be H.256 encoded MP4 format or some of the other formats as mentioned above. For a detailed specification on this, check this
Wikipedia article

HTML5 video is supported by all the modern browsers such as IE9 (currently in RC stage), Mozilla Firefox 4 and Chrome latest versions. Here below is a simple example of a HTML5 video tag and the screen shot of how it looks like in IE9 RC


<!DOCTYPE html>
<head></head>
<body>
<h1>This is a sample of an HTML5 Video</h1>
<video src="video.mp4" id="myvideo">Your browser doesn’t support this currently</video>
</body>
</html>




You can add attributes to the video tag such as “autoplay” which will automatically start playing the video. Also, you can specify “poster” to display an initial picture before the video starts playing etc., but I am not going into those for now.


This would play well in the modern browsers as mentioned above. However, if the end users are viewing this page from an earlier version of browsers such as IE8/IE7 or IE6, this video wouldn’t play. Whatever text that is specified between the video tags, would just show up.




Note: for demo purposes, I went to the IE9 developer toolbar and chose IE8 as Browser Mode to exhibit this legacy behaviour.


However, in the interest of serving the larger community of users who visit the site, we would like to have a fall back mechanism for playing videos on older version of browsers.


Now, Silverlight is supported in IE6/7 & 8 and other browsers too. If we can have the same video encoded for Silverlight, we can put the fall-back code, as follows:-


<video src="videos/video.mp4" id="myvideo">
<object height="252" type="application/x-silverlight-2" width="448">
<param name="source" value="resources/player.xap">
<param name="initParams" value="deferredLoad=true, duration=0, m=http://localhost/DemoSite/videos/video.mp4, autostart=false, autohide=true, showembed=true, postid=0" />
<param name="background" value="#00FFFFFF" />
</object>

</video>

Note, this sample uses a Silverlight XAP file with the same video and uses the object tag to embed it instead of the HTML5 video tag.


So, when I now run this sample and switch to IE8 (using the IE9 Developer toolbar’s Browser Mode), I get



and when clicking on the “Play” icon,



Note, there are multiple ways to play videos in Silverlight and this is one of the ways. For a complete list of Silverlight samples, visit http://www.silverlight.net/learn/

Also, we can use Flash to play video in the fall-back mechanism as well.

Thus, we can create a fall-back mechanism for playing HTML5 videos for the older browsers and hence ensure that the end users get to experience the same.

Cheers !!! Try Silverlight 5 Hosting with ASPHostPortal.com

 



SQL 2012 Hosting - ASPHostPortal :: Sequence in SQL Server 2012

clock May 25, 2012 07:55 by author Jervis

SQL Server 2012 (or Denali) has now arrived CTP. In this article I will look at a core new feature of SQL Server 2012 which is SEQUENCE. Well, if you are familiar with Oracle, you will already know all about this feature since it has been standard on Oracle more than 10 years I guess.

What is Sequence in SQL Server ?


In simple terms, it is a new database object and a substitute for the Identity of columns.


Using the identity attribute for a column, you can easily generate auto-incrementing numbers (which as often used as a primary key). With Sequence, it will be a different object which you can attach to a table column while inserting. Unlike identity, the next number for the column value will be retrieved from memory rather than from the disk – this makes Sequence significantly faster than Identity. We will see this in coming examples.


Creating a Sequence in SQL Server


To use Sequence first SQL Server Management Studio (SSMS) and expand the Object explorer, under programmability you will see the sequence node.




If you right click the sequence and select new, you will be taken to the below screen which has all the attributes for the sequence.




Since Sequence is a database object, it needs to be assigned to a schema. It has a data type which can be int, bigint, tinyint, smallint,numeric or decimal. The start value and increment as similar as to the values you will be familiar with using Identity.


The Minimum and maximum are boundaries for the sequence. When the cycle option is set you have the ability to re-use sequence numbers.


Similarly, Sequences can be created using T-SQL as follows.


IF EXISTS (SELECT * FROM sys.sequences WHERE name = N’EmployeeSeq’)
DROP SEQUENCE EmployeeSeq;
GO


CREATE SEQUENCE EmployeeSeq AS tinyint
START WITH 0
INCREMENT BY 5;
GO


Now let us see how we can integrate this with an Insert statement.


First we will create a table to incorporate the sequence we created.


CREATE TABLE Employee
(ID tinyint, Name varchar(150) )


Then we will insert:


INSERT INTO Employee
(ID,Name)
VALUES
(NEXT VALUE FOR EmployeeSeq, ‘Dinesh’)
INSERT INTO Employee
(ID,Name)

VALUES
(NEXT VALUE FOR EmployeeSeq, ‘Asanka’)

Note that you are now using the EmployeeSeq sequence object for the insert.

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.

 

 

 



Silverlight 5 Hosting - ASPHostPortal :: Breakpoints on Xaml in Silverlight 5

clock May 14, 2012 09:53 by author Jervis

Silverlight 5 Beta brings the enormously useful ability to set a break point in your Xaml where you have a data binding. This can greatly simplify debugging and fixing binding issues.



To see this, create a new Silverlight 5 project and set up the Xaml to have 5 rows and 2 columns. Place the title in the first row (spanning both columns) and prompts in the next 4 rows. The prompts are


- Full name

- Address
- Phone
- Email

Add four TextBlocks in the second column to display the values that will correspond to these prompts. The Xaml for the four prompts looks like this:


<TextBlock
    Grid.Column="1"
    Grid.Row="1"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding FullName}" />
<TextBlock
    Grid.Column="1"
    Grid.Row="2"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding FullName}" />
<TextBlock
    Grid.Column="1"
    Grid.Row="2"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding Address}" />
<TextBlock
    Grid.Column="1"
    Grid.Row="4"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding PhoneNumber}" />
<TextBlock
    Grid.Column="1"
    Grid.Row="4"
    Margin="5"
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Text="{Binding Email}" />

To make this work, of course, we need a class and an instance to bind to. Begin by creating a new class, Person,


public class Person
{
    public string FullName { get; set; }
    public string Address { get; set; }
    public string Phone { get; set; }
    public string Email { get; set; }
}

In MainPage.xaml.cs create an instance of Person, and set that instance to be the data context for the bindings,

public MainPage()
{
    InitializeComponent();
    var per = new Person()
    {
        FullName = "Jesse Liberty",
        Address = "100 Main Street, Boston, MA",
        Email = "[email protected]",
        Phone = "617-888-1243"
    };
    this.DataContext = per;
}

When you run this you’ll find that three of the four bindings work well, but the phone number is not displayed. Set a break point in the Xaml folder on the binding for the PhoneNumber and run the application. When you hit the break point examine the locals window as shown in the illustration to the right.



Note that there is an error message. By clicking on the message you can open a text reader for the entire error message, as shown in the next figure to the right.



The error message indicates that there is no property PhoneNumber in the type Person, and sure enough, a quick check of the code shows that the property is just Phone.

Change the binding from PhoneNumber to Phone and the program works as expected

 



ASP.NET MVC 3 Hosting - ASPHostPortal :: Set up custom error pages to handle errors in “non-AJAX” requests and jQuery AJAX requests

clock May 4, 2012 08:16 by author Jervis

In this blog post I will show how to set up custom error pages in ASP.NET MVC 3 applications to create user-friendly error messages instead of the (yellow) IIS default error pages for both “normal” (non-AJAX) requests and jQuery AJAX requests.

In this showcase we will implement custom error pages to handle the HTTP error codes 404 (“Not Found”) and 500 (“Internal server error”) which I think are the most common errors that could occur in web applications. In a first step we will set up the custom error pages to handle errors occurring in “normal” non-AJAX requests and in a second step we add a little JavaScript jQuery code that handles jQuery AJAX errors.

We start with a new (empty) ASP.NET MVC 3 project and activate custom errors in the Web.config by adding the following lines under <system.web>:

<customErrors
mode="On" defaultRedirect="/Error">
  <error redirect="/Error/NotFound" statusCode="404"/>
  <error redirect="/Error/InternalServerError" statusCode="500"/>
</customErrors>


Note: You can set
mode=Off” to disable custom errors which could be helpful while developing or debugging. Setting mode=RemoteOnly” activates custom errors only for remote clients, i.e. disables custom errors when accessing via http://localhost/[...]. In this example setting mode=”On” is fine since we want to test our custom errors. You can find more information about the <customErrors> element here.

In a next step we
remove the following line in Global.asax.cs file:

filters.Add(new HandleErrorAttribute());


and add a new
ErrorController (Controllers/ErrorController.cs):

public class ErrorController : Controller
{
  public ActionResult Index()
  {
    return InternalServerError();
  }

  public ActionResult NotFound()
  {
    Response.TrySkipIisCustomErrors = true;
    Response.StatusCode = (int)HttpStatusCode.NotFound;
    return View("NotFound");
  }

  public ActionResult InternalServerError()
  {
    Response.TrySkipIisCustomErrors = true;
    Response.StatusCode = (int)HttpStatusCode.InternalServerError;
    return View("InternalServerError");
  }
}

In a last step we add the ErrorController‘s views (Views/Error/NotFound.cshtml and Views/Error/InternalServerError.cshtml) that defines the (error) pages the end user will see in case of an error. The views include a partial view defined in Views/Shared/Error/NotFoundInfo.cshtml respectively Views/Shared/Error/InternalServerErrorInfo.cshtml that contains the concrete error messages. As we will see below using these partial views enables us to reuse the same error messages to handle AJAX errors.

Views/Error/NotFound.cshtml:
@{
  ViewBag.Title = "Not found";
}
@{
  Html.RenderPartial("Error/NotFoundInfo");
}

Views/Shared/Error/NotFoundInfo.cshtml:

The URL you have requested was not found.

Views/Error/InternalServerError.cshtml:

@{

  ViewBag.Title = "Internal server error";
}
@{
  Html.RenderPartial("Error/InternalServerErrorInfo");
}

Views/Shared/Error/InternalServerErrorInfo.cshtml:

An internal Server error occured.

To handle errors occurring in (jQuery) AJAX calls we will use jQuery UI to show a dialog containing the error messages. In order to include jQuery UI we need to add two lines to Views/Shared/_Layout.cshtml:

<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>

Moreover we add the following jQuery JavaScript code (defining the global AJAX error handling) and the Razor snippet (defining the dialog containers) to Views/Shared/_Layout.cshtml:

<script type="text/javascript">
  $(function () {
    // Initialize dialogs ...
    var dialogOptions = {
      autoOpen: false,
      draggable: false,
      modal: true,
      resizable: false,
      title: "Error",
      closeOnEscape: false,
      open: function () { $(".ui-dialog-titlebar-close").hide(); }, // Hide close button
      buttons: [{
        text: "Close",
        click: function () { $(this).dialog("close"); }
      }]
    };
    $("#InternalServerErrorDialog").dialog(dialogOptions);
    $("#NotFoundInfoDialog").dialog(dialogOptions);

    // Set up AJAX error handling ...
    $(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
      if (jqXHR.status == 404) {
        $("#NotFoundInfoDialog").dialog("open");
      } else if (jqXHR.status == 500) {
        $("#InternalServerErrorDialog").dialog("open");
      } else {
        alert("Something unexpected happend :( ...");
      }
    });
  });
</script>

<div id="NotFoundInfoDialog">
  @{ Html.RenderPartial("Error/NotFoundInfo"); }
</div>
<div id="InternalServerErrorDialog">
  @{ Html.RenderPartial("Error/InternalServerErrorInfo"); }
</div>

As you can see in the Razor snippet above we reuse the error texts defined in the partial views saved in Views/Shared/Error/.

To test our custom errors we define the HomeController (Controllers/HomeController.cs) as follows:

  public class HomeController : Controller
  {
  public ActionResult Index()
  {
    return View();
  }
  public ActionResult Error500()
  {
    throw new Exception();
  }
}


and the corresponding view
Views/Home/Index.cshtml:

@{

  ViewBag.Title = "ViewPage1";
}


<
script type="text/javascript">
  $function () {
    $("a.ajax").click(function (event) {
      event.preventDefault();
      $.ajax({
      url: $(this).attr('href'),
    });
  });
});

</
script>

<
ul>
  <li>@Html.ActionLink("Error 404 (Not Found)", "Error404")</li>
  <li>@Html.ActionLink("Error 404 (Not Found) [AJAX]", "Error404", new { }, new { Class = "ajax" })</li>
  <li>@Html.ActionLink("Error 500 (Internal Server Error)", "Error500")</li>
  <li>@Html.ActionLink("Error 500 (Internal Server Error) [AJAX]", "Error500", new { }, new { Class = "ajax" })</li>
</
ul>

To test the custom errors you can launch the project and click one of the four links defined in the view above. The “AJAX links” should open a dialog containing the error message and the “non-AJAX” links should redirect to a new page showing the same error message.


Summarized this blog post shows how to set up custom errors that handle errors occurring in both AJAX requests and “non-AJAX” requests. Depending on the project, one could customize the example code shown above to handle other HTTP errors as well or to show more customized error messages or dialogs.


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.

 



Visual Studio LightSwitch Hosting - ASPHostPortal :: How to Add URL in Navigation Menu in Visual Studio LightSwitch 2011

clock May 2, 2012 08:25 by author Jervis

As you probably know, Visual Studio LightSwitch is a tool provided by Microsoft to build business applications. In this article you will see how to add an URL to the navigation menu of a LightSwitch application.

An URL is a Uniform Resource Locator, it is also known as a web address. When we want to open a website then we write a web address in the address bar in the internet browser. If you want to add any URL in your LightSwitch navigation menu then you can do that.


Step 1
: First of all open Visual Studio LightSwitch->Click on new project->Select LightSwitch->Select LightSwitch application->Write name (AddUrl)->Ok.



Step 2
: Right-click on screens->Add screen.



Step 3
: Select new data screen->Write screen name (UrlInNavigation)->Select screen data (None)->Ok.



Step 4
: Go to Solution Explorer->Click on file view.



Step 5
: Right-click on client->Add references.



Step 6
: Select System.Windows.Browser->Ok.



Step 7
: Expand write code->Select UrlInNavigation_Run->Write code.



Code

using
System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using System.Runtime.InteropServices.Automation;
using System.Windows.Browser;
using Microsoft.LightSwitch.Client;
using Microsoft.LightSwitch.Threading;
namespace LightSwitchApplication
{
   public partial class Application
  
{
     partial void UrlInNavigation_Run(ref bool handled)
     {
        // Set handled to 'true' to stop further processing.
       
var uri = new Uri("http://www.windows2008hosting.asphostportal.com/", UriKind.RelativeOrAbsolute);
        Dispatchers.Main.BeginInvoke(() =>
        {
             if (AutomationFactory.IsAvailable)
             {
                 var shell = AutomationFactory.CreateObject("Shell.Application");
                 shell.ShellExecute(uri.ToString());
             }
             else
            
{
                 throw new InvalidOperationException();
             }
        });
     }
   }
}

Step 8 : Go to Solution Explorer->Click on logical view.

Step 9 : Right click on screens->Select edit screen navigation

Step 10 : Select UrlInNavigation->Clear->Set.

Step 11 : Run the application (Press F5).

 

 



About ASPHostPortal.com

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

 photo ahp banner aspnet-01_zps87l92lcl.png

Author Link

Corporate Address (Location)

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

Sign in