Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

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

Visual Studio LightSwitch Hosting - ASPHostPortal :: How to Simplify App Development Using Microsoft Visual Studio LightSwitch

clock July 4, 2011 05:45 by author Jervis

Microsoft's Visual Studio Live! is a developer's conference that is all about development in the Visual Studio environment. Visual Studio Live! Orlando was held at the Hilton Walt Disney World Resort in November 2010. One of the big announcements from this conference was the launch date for Visual Studio LightSwitch. And what now you can get this visual studio lightswitch hosting at ASPHostPortal.com. This article contains brief information about the benefit and the useful of Visual Studio LightSwitch.

Visual Studio LightSwitch is a rapid development environment that gives technical and somewhat technical people the ability to create lightweight, line-of-business applications. While many developers don't think Visual Studio LightSwitch will be useful for creating applications, I think it can be very beneficial to use in the right circumstances. Here are some reasons why.

Right-sized versus enterprise-ready

In recent years there has been a growing philosophy that everything needs to be enterprise-ready. The prevailing thought is that all solutions need to be scalable, flexible, "anything-able." While that is true for anything that really does need to be enterprise-ready, there are situations where enterprise-ready is too much.

Imagine you are a small startup. You are not focused on enterprise-ready. You are focused on getting through your first year. Alternately, you might be an established organization that is considering getting into a new line of business. Focusing on getting something up and running to let your employees share information in a cost-effective way would ensure that you are not risking valuable resources (that is, capital). In today's economy, capital budgets are limited (and nonexistent in some companies).

The best of both worlds

Traditionally, we have seen tools such as Access, Excel and, more recently, SharePoint, act as a useful starting point for a low-cost prototype. The best thing that can be said of those initial forays in developing line-of-business applications is that usually all of the necessary data points have been identified and there is a working prototype. I find that having a working prototype is immeasurably helpful when starting an enterprise application development effort.

While Access and Excel solutions do provide value when moving to the next level of maturation, Visual Studio LightSwitch can provide even more. Since Visual Studio LightSwitch can connect to Microsoft SQL Server or Oracle databases, the application can utilize either of those databases during the initial development.

Visual Studio LightSwitch also generates an ADO.Net Entity Framework (EF) class structure that can be used in the next iteration of development. Finally, the interface is rendered to a Microsoft Silverlight application.

Recently, I had a customer request a simple application for generating quotes for customers and tracking them in a Web format. Taking this use case, it was decided to give LightSwitch a go. We were able to build a working prototype for the need within four hours—complete with the database tables, class structure and Microsoft Silverlight interface. Normally, in a traditional Web development environment, this would have taken close to 40 hours to get to the same point.

Efficiency versus maturation

Some people point out that if this right-sized application is successful, that it will need to be rebuilt, usually from the ground up. While this is mostly true, it's relevant to restate that having a working prototype does reduce the risk (risk=time+money) in starting a new application.

So, would it be more efficient to build the enterprise-ready version of the application first? The assumption there is that you are going to get the application right the first time or that the application will be used for a period of time to recover its return on investment. But aren't those two very big assumptions? Furthermore, aren't those two very expensive assumptions?

Also, it's relevant to say that enterprise software endeavors are never guaranteed successes. We all know the high rate of failure for traditional development, whether it is done using an agile or waterfall approach. Approximately 50 percent of all features are either never used or rarely used. Why not develop those features inexpensively first and then decide what needs to be in your final application? These are the types of benefits Microsoft's Visual Studio LightSwitch can provide, making it something to consider moving forward.



Visual Studio 2010 Hosting - ASPHostPortal :: How to Create a UML Model Diagram in Visual Studio 2010

clock June 29, 2011 05:45 by author Jervis

This post discusses about how to use UML models and diagrams in Visual Studio 2010 ultimate edition. Models are very useful to describe the requirements and design of the system. Models help you to visualize how system works and clarifies the user needs and finds the architecture of the system.

1. Launch the Visual Studio 2010 and create a new project by selecting the modeling from templates window as shown below



2. In this empty project , you will find an empty .uml file which is an xml document which holds all the UML elements

3.Open the UML model viewer from View –> Otherwindows, right click on the root node and add one or more items to this model. In this example I am adding an actor to the model say Visitor and add few more actors customer and product as shown below. Actor just represent the classes of people, organisations or represent software devices which interact with system or sub systems. You can add the description to each actor in properties window.







4. We can also add use cases here, In this example I am adding Browses as an usecase. Now we can add diagrams to this model let us add an usecase diagram as shown below



5.It is blank diagram when you create but you can add the actors and usecase that we created earlier to this diagram as shown below. Drag the visitor and customer actors on the left hand side and product on right hand side, in-between add the Browses usecase. Now go to the toolbox and the associations , I am using basic association where visitor browses the product. Now I am adding a subsystem between customer and product named Ordering subsystem which contains a new usecase named buys. Let us put an association between customer and product like customer buys product. You can also add the comments to the diagram which you have created.



6.Notice that all elements which you added to the diagram are automatically appear in model explorer. There is no difference between adding the items to the explorer first and drag to the diagram and adding directly to the diagram.

7. Let us add an activity diagram to the model , Activity diagram basically shows business process or software process as a flow of work through series of actions. It is like a flow chart. Add a initial node and an action name it like visit home page and put a decision node under this and called view feature product. Add few more actions as shown below. Add a final activity node as well, use the connector to connect these actions.



8. Now look at the sequence diagram named browsing products. Sequence diagram shows the interactions which represents the sequence of messages between classes or components, systems or actors. Time flows down the diagram and you can see the message flow from start to end.



9.The typical items in sequence diagram are life lines and messages. In sequence diagram we need say where we begin, usually you can represent asynchronous message when you do not know when it is going to start. Sequence diagrams are very useful to explain the technical steps to non-technical user.

10.Now let us try to add the component diagram to the model. Component diagram basically shows the parts of the design and software system. It helps you to visualise the high-level system and service behavior. In this example the components are web servers. One is a public web server and other one say an internal server for operations. Components are going to have interfaces. Types of interfaces are provider interface and required interface. This is just an high-level view of component diagram which tells how our servers going to talk each other. You can add life line to the component diagram , which automatically adds to the sequence diagram.



This post is to give just an overview of creating UML diagrams. More useful links to learn more about UML in VS 2010 are

http://msdn.microsoft.com/en-us/vstudio/ff655021.aspx

http://msdn.microsoft.com/en-us/architecture/ff476944.aspx

Hope you enjoy the post!!

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.



ASP.NET MVC 3 Hosting - ASPHostPortal :: How to FIx "This resource cannot be found" and User.Identity.Name is blank Error

clock June 21, 2011 06:46 by author Jervis

ASP.NET MVC 3 Tools refresh recently was released and it includes a new Intranet Visual Studio project template.  This template is basically an ASP.NET MVC 3 template with Windows Authentication enabled (the Internet Application template uses forms based authentication).



I was recently playing with this template and it worked fine in development and even using the IIS 7.x Express Web Server.  However, when I deployed to a real Windows Server 2008 R2 application I saw this "The resource cannot be found" error:



So what is going on?  Notice (from the screenshot above) that we are being redirected to .../Account/Login.  This is a clue that the login/authentication is failing. The controller for login is throwing the error.

If you explicitly actually type in /Home/About you will actually get a rendered page below.  Notice in the top right corner all you see is an exclamation point.  The @User.Identity.Name code in the _Layout.cshtml is blank/NULL and causing the error (shown below that is why you only see "Welcome !"). 



Why is Windows Authentication not working?  It looks to me that this is a bug in the ASP.NET MVC 3 Intranet template....I stumbled upon this by chance, by going through the "known issues" section in the 
ASP.NET MVC 3 release notes.  It mentions that we should add this line (<add key="enableSimpleMembership" value="false" />) to the web.config if we are upgrading from an ASP.NET MVC 2 application.  This has NOTHING to do BTW with Windows Authentication and I tried adding that key in web.config by chance and it properly authenticated me.

After adding the key (and restarting the application pool), ASP.NET MVC 3 properly is able to grab the identity of the user via Windows Authentication.  Basically the appsettings section of the web.config should look like this now:

  <appSettings>
    <add key="webpages:Version" value="1.0.0.0" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="enableSimpleMembership" value="false" />
  </appSettings> 

If you receive a "This Resource Cannot be Found" error or the User.Identity.Name is blank or IsAuthenticated is false for an ASP.NET MVC application ensure:

- Windows Authentication is turned on in web.config (IIS 6 and 7)
- You are using the Integrated pipeline mode in the application pool (IIS 6 and 7)
- All the wildcard mappings and ISAPI settings are properly set up (IIS 6)
- Add the key: <add key="enableSimpleMembership" value="false" /> to the appSettings section
- If you have Kerebos/NTLM etc authentication, make sure it is configured correctly in IIS

I hope this article helped anyone who is going through this annoying issue.

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.



ASP.NET MVC 3 Hosting - ASPHostPortal :: Creating Session-less Controller in MVC3

clock June 17, 2011 06:56 by author Jervis

So, how to manage the controller’s session state? Simply we can decorate the controller class with “SessionState” attribute. [SessionState()] attribute accepts SessionStateBehaviour enumeration.

SessionStateBehaviour enumeration has the following constants.

- SessionStateBehavior.Default - ASP.NET default logic is used to determine the session state behavior for the request.

- SessionStateBehavior.Required – Full read-write session state behavior is enabled for the request.

- SessionStateBehavior.ReadOnly – Read only session state is enabled for the request.

- SessionStateBehavior.Disabled – Session state is not enabled for processing the request.



We decorated controller class with [SessionState(SessionStateBehaviour.Disabled)] to disable the session. Important point to remember when we are disabling session of the controller, we should n’t use TempData[] Dictionary to store any values with action method controller, it uses session to store it’s values. If you use TempData[] Dictionary when session is disabled on controller it will throw an exception “The SessionStateTempDataProvider class requires session state to be enabled“.

Note: In earlier release of MVC3 (Beta) [SessionState()] attribute was refereed as  [ControllerSessionState()]

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 4 Hosting - ASPHostPortal :: How to Edit Silverlight page data using Domain Service

clock June 16, 2011 06:02 by author Jervis

This post requires to create a Silverlight Business Application in Visual Studio 2010.

1. Open the Mainpage.xaml , Add the following XAML code to see the Save changes and Reject changes button

   1: <Button Content="Save Changes" Click="SaveButton_Click"
         Margin="5" 
   2:        x:Name="SaveButton"></Button>
   3: <Button Content="Reject Changes" Click="RejectButton_Click"
               Margin="5"
   4:         x:Name="RejectButton"></Button>
   5: <TextBlock x:Name="ChangeText" VerticalAlignment="Center"
      Width="Auto"></TextBlock>

2. Add the code for button click event handlers as shown below

   1: private void SaveButton_Click(object sender, RoutedEventArgs e)
   2:  {
   3:   awDept.SubmitChanges(OnSubmitCompleted, null);
   4:  }
   5: 
   6:  private void RejectButton_Click(object sender, RoutedEventArgs e)
   7:  {
   8:    awDept.RejectChanges();
   9:    CheckChanges();
  10:  }
  11: private void CheckChanges()
  12:  {
  13:   EntityChangeSet changeSet = awDept.EntityContainer.GetChanges();
  14:   ChangeText.Text = changeSet.ToString();
  15:   bool hasChanges = awDept.HasChanges;
  16:   SaveButton.IsEnabled = hasChanges;
  17:   RejectButton.IsEnabled = hasChanges;
  18:  }
  19: 
  20: private void OnSubmitCompleted(SubmitOperation so)
  21:  {
  22:    if (so.HasError)
  23:     {
  24:         MessageBox.Show(string.Format("Submit Failed: {0}", so.Error.Message));
  25:         so.MarkErrorAsHandled();
  26:      }
  27:             CheckChanges();
  28:  }

  29: private void departmentDataGrid_RowEditEnded(object sender,
          DataGridRowEditEndedEventArgs e)
  30: {
  31:          CheckChanges();
  32: }

3. Open the Metadata file in server project and add the editable attribute to the Id and modified date as shown below

   1: internal sealed class DepartmentMetadata
   2:         {
   3: 
   4:             // Metadata classes are not meant to be instantiated.
   5:             private DepartmentMetadata()
   6:             {
   7:             }
   8: 
   9:             [Editable(false)]
  10:             public short DepartmentID { get; set; }
  11: 
  12:             public string GroupName { get; set; }
  13:             [Editable(false)]
  14:             public DateTime ModifiedDate { get; set; }
  15: 
  16:             public string Name { get; set; }
  17:         }

4. When you run the application you should be able to see the below screen



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.



ASP.NET MVC 3 Hosting - ASPHostPortal :: How to Use BCrypt with ASP.NET MVC 3 and C#

clock June 14, 2011 12:33 by author Jervis

Today we will talk about how to use BCrypt with ASP.NET MVC 3 and C#. First, Open up Visual Studio 2010 and make sure you have the ASP.NET MVC 3 package installed. Create a new project: File -> New Project -> ASP.NET MVC 3 Web Application and call it MvcBCrypt. For the project template select Empty. Make sure for the View Engine you pick Razor.



Right-click on the Controllers folder and select Add -> Controller

Name the new Controller HomeController.



When the code shows up right-click on the Index() and choose Add View. Use the default settings (see below) and then click Add.



Modify the code in the Index.cshtml file to look like this:

@{
    ViewBag.Title = "Home Page";
}   

<p>Password: @ViewBag.Password</p>
<p>Hashed Password: @ViewBag.HashedPassword</p>
<p>(Use a wrong password) Is the password correct?:
@ViewBag.HashedPasswordChecked1</p>

<p>(Use the correct password) Is the password correct?: @ViewBag.HashedPasswordC

Its time to bring in the
BCrypt code now. Go to this link and copy the source code. Create a new folder in your project called Utility and create a new class file in there called BCrypt.cs.



Note: Yes, there are better places to put this new BCrypt class file but for simplicity its just going to live in a Utility folder for this demonstration.

Make sure to paste in the code and save the file. When you do this make sure to fix the namespace and remove the following:

[assembly: System.Reflection.AssemblyVersion("0.3")]

Go back to the HomeController file and modify it like so:

using MvcBCrypt.Utility;

Add the new code to test out the BCrypt class:

public ActionResult Index()
{
    string password = "myPassword1";
    string wrongPassword = "wrongPasswOrd1";   

    string hashedPassword = BCrypt.HashPassword(password, BCrypt.GenerateSalt(12));
    bool doesItMatch1 = BCrypt.CheckPassword(wrongPassword, hashedPassword);
    bool doesItMatch2 = BCrypt.CheckPassword(password, hashedPassword);   

    ViewBag.Password = password;
    ViewBag.HashedPassword = hashedPassword;
    ViewBag.HashedPasswordChecked1 = doesItMatch1;
    ViewBag.HashedPasswordChecked2 = doesItMatch2;   

    return View();
}

Save and run the project.



Note: Using the new Library Package Manager I did see another BCrypt library out there so you might want to experiment with that one as well.



ASP.NET MVC 3 Hosting - ASPHostPortal :: How to Use Controllers Scaffolding in ASP.NET MVC 3

clock June 7, 2011 08:06 by author Jervis

ASP.NET MVC 3 Tools Update introduces support for controllers scaffolding with views and data access code. Right now I am building one very simple web site for free tech events and as I am building it on ASP.NET MVC 3 I have good testing polygon right here. In this posting I will show you how controller scaffolding works and what is the end result.

You can see this image below. This is my solution.



If you have built something like this before then you should also be able to see one interesting output that I have to generate – namely event schedule. Cool, this is something I can blog about later.

Adding controller for events management

Under admin section I want to be able to manage the events. So, let’s add new controller for events. This is new Add Controller dialog and I have selected template that is based on Entity Framework (yes, I am using EF in this project).

Also notice that there is dropdown for data context class. This dropdown is filled automatically and it provides you with Entity Framework models you have in your projects.

Controller with data access methods

Image on right shows what was generated when I hit Add button. There is controller class with all methods to manage events and… this is all buggy because event, when lower cased, is keyword of C#. Here’s the example:

01.[HttpPost]
02.public ActionResult Create(Event event)
03.{
04.    if (ModelState.IsValid)
05.    {
06.        db.events.AddObject(event);
07.        db.SaveChanges();
08.        return RedirectToAction("Index"); 
09.    }
10.   
11.    return View(event);
12.}




I suppose I doesn’t compile without renaming some variables. :)

After fixing the variable names and removing comments generated by default I have controller class that looks like this.

01.public class AdminEventsController : Controller
02.{
03.    private EventsEntities db = new EventsEntities();
04.   
05.    public ViewResult Index()
06.    {
07.        return View(db.events.ToList());
08.    }
09.   
10.    public ViewResult Details(int id)
11.    {
12.        Event evt = db.events.Single(e => e.Id == id);
13.        return View(evt);
14.    }
15.   
16.    public ActionResult Create()
17.    {
18.        return View();
19.    }
20.   
21.    [HttpPost]
22.    public ActionResult Create(Event evt)
23.    {
24.        if (ModelState.IsValid)
25.        {
26.            db.events.AddObject(evt);
27.            db.SaveChanges();
28.            return RedirectToAction("Index"); 
29.        }
30.   
31.        return View(evt);
32.    }
33.   
34.    public ActionResult Edit(int id)
35.    {
36.        Event evt = db.events.Single(e => e.Id == id);
37.        return View(evt);
38.    }
39.   
40.    [HttpPost]
41.    public ActionResult Edit(Event evt)
42.    {
43.        if (ModelState.IsValid)
44.        {
45.            db.events.Attach(evt);
46.            db.ObjectStateManager.ChangeObjectState(evt,
47.               EntityState.Modified);
48.            db.SaveChanges();
49.            return RedirectToAction("Index");
50.        }
51.        return View(evt);
52.    }
53.   
54.    public ActionResult Delete(int id)
55.    {
56.        Event evt = db.events.Single(e => e.Id == id);
57.        return View(evt);
58.    }
59.   
60.    [HttpPost, ActionName("Delete")]
61.    public ActionResult DeleteConfirmed(int id)
62.    {           
63.        Event evt = db.events.Single(e => e.Id == id);
64.        db.events.DeleteObject(evt);
65.        db.SaveChanges();
66.        return RedirectToAction("Index");
67.    }
68.   
69.    protected override void Dispose(bool disposing)
70.    {
71.        db.Dispose();
72.        base.Dispose(disposing);
73.    }
74.}

As you can see then most of dirty work is already done for you. All you have to do is some little tweaking of methods so they better fit your needs.


Views

With controller we also got views for controller actions. Views are generated like they were before. Here is the example of list view of events that is generated by default.



So, nothing special for views has happened but they are generated and work well.

Conclusion

ASP.NET MVC 3 Tools Update offers controllers scaffolding feature that helps to generate CRUD methods for controllers and appropriate views. It is very cool that Entity Framework models are supported and ASP.NET MVC is able to generate working code that you can use right after generating it. Although this code usually needs some tweaking and modifications it is still useful because it saves you some time.

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 :: SQL Server Meets Microsoft Visual Studio LightSwitch

clock June 6, 2011 06:36 by author Jervis

Introduction

Developing a tool for building applications with little to no programming skills has been the goal of multiple companies over the last twenty some odd years. You would think that after all this time someone would have come up with a way to automatically generate computer programs to do just about anything. While there are some products on the market that come close, there really isn't a tool that completely writes a program for you.


Microsoft Visual Studio LightSwitch takes another shot at the no-programming-experience-needed goal with the target of building applications to run both natively and over the web. It's the culmination of several years' worth of research and development effort on the part of Microsoft aimed specifically at the relatively simple line-of-business application market. The target user of the product is someone with little-to-no programming experience but a good understanding of the business process needing to be automated.

Database Centric

LightSwitch at the core is all about building data-centric applications. When you first fire up the program and create a new project you'll be asked to either create a new data table or connect to an external data source. All the plumbing necessary to make the database connections is done for you behind the scenes. To connect to password protected data sources will require a one-time username and password and, after that, it will be automatic.

One of the new things that LightSwitch brings to the table is the idea of real-world data types like phone numbers and email addresses. In a typical business language like Visual Basic this would typically require some additional logic to take a string input field, validate that the input data looked something like a phone number (no letters, right number of digits, etc) and then save the result to a string field. Fields can also have default values or partial values such as a default domain for an e-mail address. When you create a table from scratch, LightSwitch actually fires up a copy of Microsoft SQL Express with a file-attached data source.



To talk to external SQL databases LightSwitch uses EDM. This provides direct access to all the popular SQL database engines including Microsoft SQL Server, Oracle and more. LightSwitch also uses the recently released Windows Communication Foundation (WCF) Rich Internet Application (RIA) services to communicate between the application and any external data source, including Cloud SQL Azure.

Out-of-the-box (OOTB) support for SharePoint as an external data source makes LightSwitch a great candidate for apps to manipulate any SharePoint table. The development environment provides a simple relationship builder tool to establish links between different tables. You don't have to be a programmer or a database expert to use the tool.

Simplified User Interface Construction

In doing the research for this product, Microsoft identified a number of common elements that tend to repeat themselves with typical business applications. For user interaction this typically involves a set number of screens for inputting, searching, editing and displaying data of some type. LightSwitch provides all of these patterns as options when you select Add New Screen.



LightSwitch uses a XAML-based syntax for both the screen layout and data schema definitions. It is not, however, the same XAML you would get when building a Silverlight application using the full Visual Studio experience. LightSwitch goes to great lengths to take care of the more mundane code needed to do most of the common tasks that every application must do. For example, every grid in a LightSwitch native app comes with the ability to directly export to Excel without the need to write any code.

Customizing user screens happens while the application is actually running. When you run an application, you'll see an icon in the upper right corner titled "Customize Screen." Clicking this icon brings up a Customization Mode window with a multitude of options, allowing you to change the layout of your screen. The tool uses a template system with a set of default templates for displaying typical data layouts and includes the ability to extend the templates should the need arise.



When you're ready to publish your app, simply follow the instructions provided from the publish option on the Build menu. That's pretty much all there is to it.

Final Notes

If you are a current MSDN subscriber, you'll be happy to know that when LightSwitch ships it will be integrated into the Visual Studio Pro and Ultimate product lines so you'll have the option when creating a new project to build a LightSwitch solution. The product will also be available as a stand-alone offering for anyone that's not a current Visual Studio or MSDN customer. Thanks for reading.

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 :: The Powerfull of LightSwitch Application

clock May 31, 2011 05:37 by author Jervis

Visual Studio LightSwitch is built on two basic concepts; data and screens which are used to create typical business applications.

Obviously, there is more to it than that but generally when developing a business application, you start with a piece of data. This can take the form of local data or a connection to an external data source of some description. You describe this data in your application and then build your application in order to manipulate the data as required. The second step involves providing a mechanism to interact with that data. This is generally accomplished by designing screens which allow users to perform standard CRUD (create/read/update/delete) operations on the data. Ultimately, a combination of screens makes a business application.



Business application developers should immediately see the  benefits of LightSwitch once they start to get their hands dirty with it. However, in general, Business Intelligence (BI) projects are not really about building business applications, rather they provide the means to analyse the data being produced by such business applications. However, many BI projects face the same challenge, namely how to manage master data or some other data. Commonly, BI solutions require that a number of tables in the database require content which needs to be managed by the users. More often than not, database tools are used to manage these tables but this is not an ideal solution as generally users expect a more user-friendly way to do this and database tools such as Management Studio are far too powerful for managing this sort of data.

So how have we solved this problem in the past? I cannot speak for all BI solution providers, but at Altius we’ve been solving this problem by writing custom applications to let users to manage data. Such custom applications have been written in such languages as VB 6, ASP.NET, C# and WPF. More importantly, most have been created from scratch which has created additional overhead to the project.



By using LightSwitch, instead of writing all those applications, can we very quickly create an application for the users to manage their master data such as user permissions or dimension data. The beauty of LightSwitch is that you can leverage the data regardless of where it is. Your data can come from SQL Server (local and remote), SharePoint, Azure, or even .NET WCF Services.

LightSwitch also provides some really powerful integration functionality with common business tools. For example, you can export any list to Excel with no coding whatsoever or with some minor custom code create reports in Word or PowerPoint.

Another powerful feature is that while creating your LightSwitch application you don’t need to think about it how you are ultimately going to deploy it. LightSwitch applications can be deployed as web-based applications or desktop applications.

One word of warning however. LightSwitch relies on the use of SilverLight. This allows the decision around deployment to be made late during development. This could obviously cause issues if the organisation you are working in does not have SilverLight installed on the client machines. Generally, such applications for managing BI data would only be available to a small set of users so some concessions could be made for these users.

There are many powerfull features of LightSwitch application. We have launched our new LightSwitch hosting. Please visit our site for more information about our new product.

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.



ASP.NET MVC 3 Hosting - ASPHostPortal :: Ajax in ASP.Net MVC 3

clock May 27, 2011 06:23 by author Jervis

In asp.net web form application, if we need ajax service, we will need to create wcf services on server side to serve ajax calls, while in MVC web application(version 3), no wcf is needed, a controller will do.

Here are two examples (GET and POST) of how to use ajax in mvc application

Http Get example: ajax consumer in view

 <script type="text/javascript">
  var user = {
                'id': 1
            };   

    $.get(
                'home/getUser',
                user,
                function (data) {
                    alert(data.name);
                }   

    );
</script>

Http Get example: ajax server in home controller


public class HomeController : Controller
{
    // data GET service
     public JsonResult getUser(int id)
     {   

            User user = db.Users.where(u=>u.id==id)   

            return Json(user,JsonRequestBehavior.AllowGet);
     }   

}

A few points:

Controller must return JsonResult rather than ActionResult as a normal controller does as we would want the data to be returnd as json data, and it does not have a ‘d’ wrapper

JsonRequestBehavior.AllowGet must be set in Json()call, otherwise you will get:

500 internal server error with message like

This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet

You only need to set this parameter for GET and returning JSON array to avoid JSON hijacking, no need for POST requests.
Http POST example: ajax consumer in view


<script type="text/javascript">
var user={
            'name':’TheUser’,
            'age':30
        };  

 $.post(
            'home/SaveUser',
            user,
            function (data) {
                if (data === true) {
                   alert('User is saved');
                }
                else {   

                    alert('Failed to save the user');   

                }
            },
            'json'
        );
</script>

Http POST example: ajax server in home controller

public class HomeController : Controller
{
    // data POST service
  [AcceptVerbs(HttpVerbs.Post)]
   public JsonResult SaveUser (string name, int age)
   {   

        return Json(true);
    }
}

A few points:

Have to decorate the controller with ‘POST’

Datatype in $.post in example is set to json, but it is not necessary to be so, if you just pass data in fields rather than in complex object. When it is not set to json it will use application/x-www-form-urlencoded as a way to pass data in standard post.

Summary:
In asp.net MVC you can use controller as ajax server without having to use wcf, compared with wcf, no configuration is needed.


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.



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