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

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

Press Release - ASPHostPortal.com Proudly Launches osCommerce 3.0.2 Hosting

clock January 30, 2014 10:06 by author Mike

ASPHostPortal.com is a premiere web hosting company that specializes in Windows and ASP.NET-based hosting with innovative technology  solutions, proudly announced the best osCommerce 3.0.2 hosting service with a combination of affordable price, high customer  satisfaction rate and commendable quality in all ASP.NET and Windows web hosting plans.

osCommerce 3.0.2 are made to showcase the new features being worked on and to generalize a version specific for testing to help fix  and improve subsequent alpha releases for a final, stable, secure, and production ready 3.0.2 releases. The osCommerce solution offers  great flexibility and empowers even amateur webmasters to develop highly competitive ecommerce websites.

Until recently, the cost involved in hiring a web development company to develop a similar ecommerce web site was prohibiting several  small businesses from selling on-line. The osCommerce solution is one of the best fruits of the open source community and which poses  a serious challenge to other similar commercial software products.


Installation for this software can be performed easily from within the web hosting control panel, even by customers with poor  programming experience. The installation process takes up to a minute to perform, thus enabling customers to deploy an entire  ecommerce storefront for their business within a few clicks of the mouse.

ASPHostPortal.com
is the among the few top web hosting company that tested and offer ASP.NET hosting plan that compliance with  osCommerce 3.0.2 hosting. There are several companies out there that offer e-Commerce hosting plan but at ASPHostPortal.com, we provide quality e-Commerce  hosting plan at affordable prices that will not only keep your operating costs low but also help you to maximize your profits.

ASPHostPortal.com
development teams have fully tested and deployed the latest osCommerce 3.0.2 in hosting control panel systems.  Clients can install and use osCommerce 3.0.2 hosting with few clicks of installation steps. For more information about this topics or  have any enquiries related to osCommerce hosting, please visit http://www.asphostportal.com/osCommerce-Hosting.

About the Company
ASPHostPortal.com is a hosting company that best support in Windows and ASP.NET-based hosting. Services include shared hosting,  reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server, and architecting highly scalable solutions. As a  leading small to mid-sized business web hosting provider, ASPHostPortal.com strive to offer the most technologically advanced hosting  solutions available to all customers across the world. Security, reliability, and performance are at the core of hosting operations to  ensure each site and/or application hosted is highly secured and performs at optimum level.



ASPHostPortal.com Proudly Launches nopCommerce 3.2 Hosting

clock January 23, 2014 10:36 by author Mike

ASPHostPortal.com is a premiere web hosting company that specializes in Windows and ASP.NET-based hosting with innovative technology  solutions, proudly announced the best nopCommerce 3.2 hosting service with a combination of affordable price, high customer  satisfaction rate and commendable quality.

nopCommerce is an open source e-commerce solution that contains both a catalog frontend and an administration tool backend.  nopCommerce is a fully customizable shopping cart. It's stable and highly usable. From downloads to documentation, nopCommerce.com  offers a comprehensive base of information, resources, and support to the nopCommerce community. The latest version of nopCommerce is  3.2 with lots of awesome features.

The first feature that will grab the attention of every nopCommerce store owner is the new Facebook Shop. The next major functionality  that comes with nopCommerce 3.20 is its support for warehouses. What this means is that you can configure individual products to be  shipped from a specific location (warehouse). You can also configure the system to use the warehouse location when calculating the  shipping cost for the product. While we are on the nopCommerce 3.20 shipping functionality, there is another new feature worth  mentioning. Now the store owner can specify when a product will be shipped. In nopCommerce this information is referred to as delivery  date. This is useful for example when you are selling products, which are manufactured on demand.

Nopcommerce 3.2 is simply the best and most powerful open source shopping cart on the planet. It is the only open source shopping  cart application that supports both multi-sites and multi-vendors. NopCommerce is fast, easy, and fun. I definitely recommend  NopCommerce to anyone who wants to start an online business.


ASPHostPortal.com
is a popular online nopCommerce 3.2 hosting service provider with all of its hosting plans to help users to automate  and simplify website and server administration tasks such as installation and migration. There are several companies out there that offer e-Commerce hosting plan but at ASPHostPortal.com provide quality e-Commerce  hosting plan at affordable prices that will not only keep your operating costs low but also help you to maximize your profits.

nopCommerce is ASP.NET 4.0 based supporting MS SQL databases. It features an embedded graphic installer, so nopCommerce can be setup  in few minutes and run immediately. For more information about this topics or have any enquiries related to nopCommerce hosting,  please visit http://www.asphostportal.com/nopCommerce-Hosting.

About the Company
ASPHostPortal.com is a hosting company that best support in Windows and ASP.NET-based hosting. Services include shared hosting,  reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server, and architecting highly scalable solutions. As a  leading small to mid-sized business web hosting provider, ASPHostPortal.com strive to offer the most technologically advanced hosting  solutions available to all customers across the world. Security, reliability, and performance are at the core of hosting operations to  ensure each site and/or application hosted is highly secured and performs at optimum level.



ASP.NET MVC 5 Hosting :: Customizing ASP.NET MVC 5/Web API 2 Scaffolding Templates in Visual Studio 2013

clock January 20, 2014 17:25 by author Mike

In this article, I showed you how you can easily customize the default code generation(scaffolding) templates in ASP.NET MVC 5 and ASP.NET Web API 2 using Visual Studio 2013.

Scaffolding in ASP.NET allows you to automatically generate code in web application. This make it easy to quickly add boilerplate code in your application. There is a nice introduction of scaffolding in ASP.NET application using Visual Studio 2013 at here. The default templates are good for a lot of cases, but sometimes you want to customize these scaffolding templates for all your applications and sometimes you need to use different scaffolding templates in different projects. In this article, I will show you how to customize the default scaffolding t4 templates in ASP.NET MVC 5 and ASP.NET Web API 2 globally and per project.

Description:

If you need to customize the scaffold templates globally then just navigate to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates(depending upon where Visual studio reside),

In the above explorer, you can globally update the t4 templates of ASP.NET MVC 5 and ASP.NET Web API 2.

Now for per project base, just create a CodeTemplates folder in your application root and paste the above folders inside CodeTemplates folder,

Hopefully this article useful for someone.



Press Release - ASPHostPortal.com Proudly Launches DotNetNuke (DNN) 7.2 Hosting

clock January 16, 2014 06:08 by author Mike

ASPHostPortal.com is a premiere web hosting company that specializes in Windows and ASP.NET-based  hosting with innovative technology solutions, proudly announced the best DotNetNuke (DNN) 7.2 hosting  service with a combination of affordable price, high customer satisfaction rate and commendable quality.


DotNetNuke is an open source web content management system that is built on ASP.net infrastructure and  solely has its life wire running smoothly on Microsoft platform. Furthermore, it is an open source web  content management system that started in the year 2002 by a team of developers which was headed by the  original creator Shaun Walker who happens to have bagged his certification as a certified Microsoft Most  Valuable Professional in the year 2004 and the latest version is 7.2 with lots of awesome features.

DotNetNuke (DNN) 7.2 includes a number of new features and enhancements that will benefit users and  developers alike along with a large number of bug fixes. DNN 7.2 version incorporates some of the  interesting features to elevate the existing functionality and make your site administration process a  lot easier. DNN 7.2 also allows you to install JavaScript libraries as first party extensions. Once  installed your module or skin can request that JavaScript library and the platform will automatically  add the library into the page. The API mirrors the one used for jQuery and JQuery UI making it very easy  to use.

Some benefits that the DotNetNuke content management system includes are greater site consistency,  improved site navigation, streamlined authoring process, faster turnaround time for new pages and  changes, increased site flexibility, support for decentralised authoring, increased security, reduced  duplication of information, greater capacity for growth, and reduced site maintenance costs. DotNetNuke is the best CMS (content management system) for businesses and  is easier to create and manage with ASPHostPortal.com.

ASPHostPortal.com is a popular online DotNetNuke (DNN) 7.2 hosting service provider with all of its  hosting plans to help users to automate and simplify website and server administration tasks such as  installation and migration. For more information about this topics or have any enquiries related to DotNetNuke (DNN) 7.2 hosting,  please visit http://www.asphostportal.com/DotNetNuke-Hosting

About the Company
ASPHostPortal.com is a hosting company that best support in Windows and ASP.NET-based hosting. Services  include shared hosting, reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server,  and architecting highly scalable solutions. As a leading small to mid-sized business web hosting  provider, ASPHostPortal.com strive to offer the most technologically advanced hosting solutions available to  all customers across the world. Security, reliability, and performance are at the core of hosting  operations to ensure each site and/or application hosted is highly secured and performs at optimum  level.



.NET Entity Framework Hosting - ASPHostPortal.com :: Using Database Migration

clock January 7, 2014 09:16 by author Mike

Entity Framework (EF) is an object-relational database mapper that enables easy database access for .NET developers using domain-specific .NET objects that EF can generate for you. As we saw in the first blog post on Entity Framework, you can use EF to create your database from the classes you have defined in your project code. You can add or remove properties from your classes and have EF migrate the changes into your database as well.

As developers, you often face projects where the specifications change over time for many reasons. Sometimes the client isn’t sure exactly what they need or their needs change during the course of the project. The design and analysis may determine that you need to add fields to the database or even remove fields from the database for one reason or another. For example, you may have new requirements to keep track of a user’s email address. Or you may need to add and track a user’s cell phone. A field/column entitled fName may even need to be renamed to firstName, or maybe you need to split a name into separate fields. There are many reasons that database fields/columns may need to change on a given project.

See the following classes:

   public class Seminar
    {
        public int SeminarId { get; set; }
        public string Name { get; set; }
        public virtual List Topics { get; set; }

    }

    public class Topic
    {
        public int TopicId { get; set; }
        public string Title { get; set; }

        public int SeminarId { get; set; }
        public virtual Seminar Seminar { get; set; }
    }

And our database looked like this:

Now, for the sake of our discussion, let’s say that we already have run our application at least once so our database has already been created, and we have decided that we want to add the keynote speaker’s name to the database. We can do that by just adding it as a property in our SeminarID class and then getting a DBA to write the necessary SQL. If you were allowed, you could write the SQL to add the field/column to the database table. That would just modify the database, however, and that is not the best approach since you may need to change it later. The best approach is to automate tracking and manage the migrations as the project grows. To do that we will use Code First Migrations.

First, you need to enable Code First Migrations using the Package Manager Console. If it isn’t already open, select Tools->Library Package Manager->Package Manager Console. Now run the command shown below. Notice that we used the Namespace of our application and the name of our DbContext class to create a fully qualified context:

Enable-Migrations -ContextTypeName SafariCodeFirst.SeminarContext

Visual Studio will process the command and you should get a result that looks something like this:

You will also get a new Migrations folder added to your project that contains two files.

Configuration.cs contains the settings that Migrations uses to do its magic work. We won’t touch it for this blog post, but in a future post we will show you how to use it to provide seed data for your database. The other file is named <timestamp>_IntialCreate.cs and contains the code shown here:

namespace SafariCodeFirst.Migrations
{
    using System;
    using System.Data.Entity.Migrations;

    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Seminars",
                c => new
                    {
                        SeminarId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.SeminarId);

            CreateTable(
                "dbo.Topics",
                c => new
                    {
                        TopicId = c.Int(nullable: false, identity: true),
                        Title = c.String(),
                        SeminarId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.TopicId)
                .ForeignKey("dbo.Seminars", t => t.SeminarId, cascadeDelete: true)
                .Index(t => t.SeminarId);

        }

        public override void Down()
        {
            DropIndex("dbo.Topics", new[] { "SeminarId" });
            DropForeignKey("dbo.Topics", "SeminarId", "dbo.Seminars");
            DropTable("dbo.Topics");
            DropTable("dbo.Seminars");
        }
    }
}

Closer examination shows that it contains the code to take you from an empty database to one that contains the tables for the Seminar and Topic classes defined in our code.

Now that we have enabled Migrations and the basics are all in place, let’s modify our Seminar class to add a key note speaker so that our Seminar class now looks like this:

   public class Seminar
    {
        public int SeminarId { get; set; }
        public string Name { get; set; }
        public string Speaker { get; set; }
        public virtual List<Topic> Topics { get; set; }

    }

Next, we need to run migrations again using the command Add-Migration AddSpeaker. You can give this any name you want, but it is good to make it descriptive of the changes. Add-Migration will check for changes between the model classes and the last migration that was run, createing a new migration. You will notice that it is called <timestamp>_AddSpeaker.cs, and it has been added to the Migrations folder in our project. The timestamp part of the name is what Migrations uses to keep changes in order to track which changes have been applied. Now we need to run Update-Database so that any pending changes get applied to the database. I like to use the –Verbose switch so that I can see what is going on.

Now if you refresh the database in Server Explorer you will see that your changes have taken place and the new field/column have been added to the Seminars table.

We can go on and on like this, adding and dropping properties from our model classes and running the Add-Migration and Update-Database commands, as our database changes over the life cycle of our application. We still need to manually add code to the application to collect the user’s input or display the data to the user, but as you have seen, all of the hard work in our project has been taken care of for us by the Entity Framework and Code First Migrations.



ASP.NET 4.5 Hosting with ASPHostPortal.com :: How to Send E-mail using ASP.NET 4.5

clock December 7, 2013 11:41 by author Mike

If you build a large site then you will be required to provide a facility for the users to contact the relevant department or web master through online form. This is the best way to prevent spam messages as users will not know the real e-mail id. The whole process of sending emails from an ASP.NET form has been simplified with the release of .NET Framework 4.5.

Look at the below figure where I added few Textbox controls.


Figure_1


You need to substitute FROM EMAIL ID, MAIL SERVER NAME, EMAIL ID and PASSWORD on the below code with relevant correct values.

Copy the code given below after providing correct values as mentioned above using Notepad, save it as an .aspx file and upload to your web server. The below code requires access to a shared Windows hosting server with ASP.NET 4.5:

<%@ Page Language="VB" %>
<%@ Import Namespace = "System.Net" %>
<%@ Import Namespace="System.Net.Mail" %>
 
<script runat="server">  
 
    Protected Sub btnSubmit_Click1(sender As Object, e As EventArgs)
        Dim mail As New MailMessage()
 
        mail.To.Add(txtEmail.Text)
        mail.From = New MailAddress("FROM EMAIL ID")
        mail.Subject = "Contact Form"
 
        mail.Body = txtName.Text & vbCrLf & txtComments.Text
 
        Dim smtp As New SmtpClient("MAIL SERVER NAME")
        smtp.Credentials = New NetworkCredential("EMAIL ID", "PASSWORD")
 
        smtp.Send(mail)
        lblStatus.Text = "Your data has been submitted successfully"
        txtName.Text = ""
    txtEmail.Text = ""
    txtComments.Text = ""
 
    End Sub
</script>
 
<html>
 
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Contct Form Demo</title>
</head>
 
<body>
    <form id="form1" runat="server">
        Name -
        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
        <br />
        <br />
        Email -
        <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
         <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
 
ErrorMessage="Please Enter Valid Email ID" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)
 
*"></asp:RegularExpressionValidator>
        <br />
        <br />
        Comments -
        <asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine" Height="71px" Width="301px"></asp:TextBox>
        <br />
        <br />
        <asp:Label ID="lblStatus" runat="server"></asp:Label>
        <br />
        <br />
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click1" />
        <br />
        <br />
    </form>
</body>
</html>

Figure_2

In the above code, I have enabled validation for E-mail ID field. This means that if you forgot to enter e-mail id in correct format you will not be able to submit the form.

Looking for quality ASP.NET 4.5 Hosting? Look no further than ASPHostPortal.com Hosting!



BlogEngine .NET 2.8 Hosting, Latest Version of BlogEngine .NET

clock December 4, 2013 09:09 by author Mike

BlogEngine.NET 2.8 is an open source .NET blogging project that was born out of desire for a better blog platform. A blog platform with less complexity, easy customization and one that takes advantage of the great features in .NET.

BlogEngine.NET 2.8 is easily customizable with have many downloadable themes, widgets, and extensions or you could make your own with some basic .NET skills. With BlogEngine.NET, it is easy to make your blog look and function exactly how you’d like.

BlogEngine.NET 2.8 Features
Here's a short list of all the features of BlogEngine.NET 2.8:

  • Plug 'n play - BlogEngine.NET is very easy to setup and customize. To make it work, just upload the files to an ASP.NET 4.0 webserver and you’re ready to start writing. No database configuration, just plug 'n play.
  • Full featured - BlogEngine.NET comes with all the features you would expect from a modern blog engine as well as new unique features such as AJAX comments and screenshot trackbacks.
  • Web 2.0 - BlogEngine.NET features social bookmarks, OpenSearch support, XFN tags, AJAX, FOAF, SIOC, APML, Gravatars, coComments, tag cloud, Google sitemap and other so called Web 2.0 features.
  • Referrer stats - The referrer statistics enables you to see which websites link to you, so you can follow up with comments or just to have fun. This feature is a real time killer that you cannot live without.
  • Cool widgets - There is a variety of cool widgets that such as an AJAX post calendar or a blogroll that automatically retrieves the latest posts from each blog and displays the title beneath the blog. Most of the controls are configurable from the admin section.
  • Advanced comment system - Comments are a very important part of a blog, so BlogEngine.NET features a very advanced commenting system in AJAX that supports country flags, live preview, Gravatars, coComments – all of which can easily be modified in the admin section.
  • Full syndication suite - BlogEngine.NET supports syndication feeds in any possible location. You can find feeds on comments, categories, authors and a main feed. Both RSS 2.0 and ATOM 1.0 are fully supported.
  • Trackbacks and pingbacks - All outgoing links from the posts is tracked- and pinged back, so your blog will get listed in the comments on the linked website if it supports it. When a new post is created, BlogEngine.NET automatically pings Technorati, Feedburner, Ping-o-Matic etc.
  • Search - The search capability of BlogEngine.NET is one of the most advanced and it even allows the visitors to search in the comments. Everything about the search can be configured in the admin section.
  • Standalone pages - Besides regular blog posts, BlogEngine.NET supports the creation of static pages that exist outside the blog chronology. Pages are useful for all kinds of information about you or your blog.
  • Multi-author support - BlogEngine.NET fully supports multiple authors to write posts on the same blog. Visitors are then able to subscribe to the individual author’s RSS feed or view only the posts from their favourite author.
  • Cool themes - BlogEngine.NET comes with some very cool themes for you to choose from. If you want to modify or create a new theme you can do so easily with just a basic understanding of HTML and CSS.
  • XHTML compliance - All the controls in BlogEngine.NET are 100% XHTML 1.0 compliant. All posts you write automatically become compliant thanks to the tinyMCE text editor.
  • Extendable - BlogEngine.NET is built from the ground up using nothing but C# and ASP.NET 4.0 all with simplicity in mind. It means that you can write new controls and themes by using the skills you already have as a .NET developer.


IIS Hosting - ASPHostPortal.com :: Using SSL in ASP.NET Web API

clock December 3, 2013 12:02 by author Mike

SSL works on the public-private key encryption and requires an SSL Certificate on the server. SSL certificates come in different flavors and normally some third party agency issues them to you. Once obtained you need to enable and install the certificate on your web server. For the sake of testing you can create a test certificate in IIS or you can also use IIS Express SSL URL for the communication. Let's quickly see how both of these options can be used.

Using SSL in IIS

Let's first see how to create a test certificate in IIS. Open IIS manager and select the server under the connections pane. Locate Server Certificates in the Features view and double click on it.Server Certificates.

Server Certificates

Server Certificates

Then click on the "Create Self-signed Certificate" link from the actions page to open a dialog as shown below:

Create Self-Signed Certificate
Create Self-Signed Certificate

Enter some friendly name for the certificate and click on OK. You should now have an entry for this new certificate under Server Certificates.

Your New Certificate
Your New Certificate

Notice that in addition to your newly created certificated there is already an entry for IIS Express Development Certificate.

Next, select the website where you wish to install the certificate and click on the Bindings option under the Edit site section of the Action pane. Add HTTPS binding using the newly created certificated as shown below:

Add Site Binding
Add Site Binding

Keep the default port number unchanged, select your certificate name in the SSL certificate dropdownlist. Click OK to close the dialog.

Using SSL in IIS Express

If you are using IIS Express as the development server, things are quite easy. Just select the project in the Solution Explorer and press F4 to open its Properties window.

Project Properties
Project Properties

Set the SSL Enabled property to True. Setting SSL Enabled to True will reveal the SSL URL. In this case it is https://localhost:44300/. You should use this URL while making Web API calls.

Forcing Requests to Use SSL

In many cases you will have both HTTP and HTTPS bindings to your website and you may want to ensure that Web API is called only over HTTPS. To accomplish this task you need to create a custom authorization filter. So, add a class in the Web API project, name it as UseSSLAttribute. Inherit UseSSLAttribute class from AuthorizationFilterAttribute class. The following code shows the completed UseSSLAttribute class:

 public class UseSSLAttribute:AuthorizationFilterAttribute
{
  public override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)
  {
    if (actionContext.Request.RequestUri.Scheme != Uri.UriSchemeHttps)
    {
      HttpResponseMessage msg = new HttpResponseMessage();
      msg.StatusCode = HttpStatusCode.Forbidden;
      msg.ReasonPhrase = "SSL Needed!";
      actionContext.Response = msg;
    }
    else
    {
      base.OnAuthorization(actionContext);
    }
  }
}

As you can see the UseSSLAttribute class overrides the OnAuthorization() method of the AuthorizationFilterAttribute. Inside the OnAuthorization() method the current scheme of the incoming request is checked using the RequestUrl.Scheme property. If the scheme is anything other than Uri.UriSchemeHttps a new HttpResponseMessage is constructed. The StatusCode property of the response message is set to Forbidden indicating that the server refused to process the request. The ReasonPhrase includes a short phrase describing the reason for refusal. This text will be displayed to the end user via jQuery code in case HTTPS is not used to access the Web API. Finally, the Response property of the actionContext parameter is set to the newly constructed message.

Now you can decorate the Web API action methods using the UseSSL attribute. The following  code shows a GetColors() method that has [UseSSL] attribute applied.

public class ColorController : ApiController
{
  [UseSSL]
  public IEnumerable<string> GetColors()
  {
    return new string[] { "Blue", "Red", "Yellow" };
  }
}

To call the GetColors() method you can use the following jQuery code from a view.

$(document).ready(function () {
  $("#button1").click(function () {
    var options = {};
    options.url = "/api/color";
    options.type = "GET";
    options.contentType = "application/json";
    options.success = function (result) { alert(result); };
    options.error = function (err) { alert(err.statusText); };
    $.ajax(options);
  });
});

 

The above code assumes that the Index view has a button with ID button1 and clicking on the button will invoke the Web API. As you can see the URL is set to /api/color. The type is GET. The success function simply displays the return value of GetColors() method using an alert dialog. Similarly the error function displays the statusText of the err object using an alert dialog. If you run the application and try to invoke the above code over HTTP you will get an error as shown below:

Error Message
Error Message

Now switch to the HTTPS URL - https://localhost:44300/ - as mentioned earlier and try invoking the same code again. While using SSL your browser may give you a warning as shown below:

Warning Message
Warning Message

This warning is issued since you are using a test certificate. Click on the Continue to this website option and invoke the code. This time you should get the color values successfully.

Color Values
Color Values


If your website deals with sensitive data it is recommended to use Secure Sockets Layer or SSL. SSL establishes an encrypted channel of communication between the server and client browser. To use SSL you must install a server side certificate. For the sake of testing you can create a test certificate using IIS or use an inbuilt mechanism of IIS Express. To enforce SSL on Web API you can create a custom authorization filter that checks the request scheme. If the scheme is HTTPS only then the call is processed, otherwise an error is sent to the client.



Visual Studio Hosting :: Configuration and Environment Variables in Visual Studio 2010

clock November 27, 2013 05:33 by author Mike

Environment variables are a great thing for when you publish your website to multiple places. It doesn't matter if you publish it to testing / staging / production environment or if you're publishing your site to several servers which require different methods to be called / different values assigned to parameters.

Let's create a web application project:

1. Open Visual Studio 2010
2. Create New Project -> ASP.NET Web Application

As you can see, you automatically have two configuration options:
- Debug
- Release

3. Right click on the project in the Solution Explorer. Click on Properties and click on Build tab.

4. Under that tab you have many configuration options. The field we're interested in is "Conditional compilation symbols". While on Debug mode, we will write a variable name in this field. Example: "vDebug"

5. After saving, you will have an identifier for when in Debug mode.
6. Before testing our work, we're gonna create another Configuration. Click on the configuration drop down list and choose Configuration Manager
.

7. Add new Configuration - TestRelease:

 

8. Now place the variables in Release Configuration and in TestRelease Configuration. I've placed the variables: vRelease and vTestRelease
9. Now for the test. Create a similar code on your Default.aspx.cs page:

When you will run the code, you'll see that for each configuration option it will it the correct method.



ASP.NET MVC 4 Hosting :: Partial View in ASP.NET MVC 4

clock November 22, 2013 10:10 by author Mike

Partial view is like a regular view with a file extension .cshtml. We can use partial views in a situation where we need a header, footer reused for an MVC web application. We can say that it’s like a user control concept in ASP.NET. Here I am going to explain how to create a partial view in an MVC 4 ASP.NET application.

First add a view to the shared folder with the view name _Product. The best way to create a partial view is with the name preceded by '_', because the name specifying that it is reusable.

Here in this example, I am using the partial view to display the item selected in the webgrid.

@model PartialViewSample.Models.Product

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>AddProduct</title>    
</head>
<body>
    <div>      
           <label>Id:</label>
            @Html.TextBox("Id", Model.Id)
             <label>Name:</label>
            @Html.TextBox("Name", Model.Id)
             <label>Description:</label>
            @Html.TextBox("Description", Model.Description)
             <label>Quantity:</label>
            @Html.TextBox("Quantity", Model.Quantity)
    </div>
</body>
</html>

We can call the partial view in a normal view like:

Html.RenderPartial("~/Views/Shared/_Product.cshtml", product);

Or

@Html.Partial("~/Views/Shared/_Product.cshtml", product);

Html.Partial returns a string, Html.RenderPartial calls Write internally, and returns void. You can store the output of Html.Partial in a variable, or return it from a function. You cannot do this with Html.RenderPartial because the result will be written to the Response stream during execution. So @html.RenderPartial() has faster execution than @html.Partial() due to RenderPartial giving quick response to the output.

We can call the partial view if the grid has a selected item. The code block is shown here:

@if (grid.HasSelection)
{
    product =(PartialViewSample.Models.Product)grid.Rows[grid.SelectedIndex].Value;        
    Html.RenderPartial("~/Views/Shared/_Product.cshtml", product);           
}



Cheap ASP.NET 4.5 Hosting

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

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


Author Link


 

Corporate Address (Location)

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

Tag cloud

Sign in