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

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

ASP.NET Hosting - ASPHostPortal.com :: Understanding Personalization in ASP.NET

clock December 23, 2016 10:07 by author Dan

Web sites are designed for repeated visits from the users. Personalization allows a site to remember the user identity and other information details, and it presents an individualistic environment to each user.

ASP.NET provides services for personalizing a web site to suit a particular client's taste and preference.

Understanding Profiles

ASP.NET personalization service is based on user profile. User profile defines the kind of information about the user that the site needs. For example, name, age, address, date of birth, and phone number.

This information is defined in the web.config file of the application and ASP.NET runtime reads and uses it. This job is done by the personalization providers.

The user profiles obtained from user data is stored in a default database created by ASP.NET. You can create your own database for storing profiles. The profile data definition is stored in the configuration file web.config.

Example

Let us create a sample site, where we want our application to remember user details like name, address, date of birth etc. Add the profile details in the web.config file within the <system.web> element.

<configuration>
<system.web>

<profile>
   <properties>
      <add name="Name" type ="String"/>
      <add name="Birthday" type ="System.DateTime"/>
     
      <group name="Address">
         <add name="Street"/>
         <add name="City"/>
         <add name="State"/>
         <add name="Zipcode"/>
      </group>
     
   </properties>
</profile>

</system.web>
</configuration>

When the profile is defined in the web.config file, the profile could be used through the Profile property found in the current HttpContext and also available via page.

Add the text boxes to take the user input as defined in the profile and add a button for submitting the data:

Update Page_load to display profile information:

using System;
using System.Data;
using System.Configuration;

using System.Web;
using System.Web.Security;

using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      if (!this.IsPostBack)
      {
         ProfileCommon pc=this.Profile.GetProfile(Profile.UserName);
        
         if (pc != null)
         {
            this.txtname.Text = pc.Name;
            this.txtaddr.Text = pc.Address.Street;
            this.txtcity.Text = pc.Address.City;
            this.txtstate.Text = pc.Address.State;
            this.txtzip.Text = pc.Address.Zipcode;
            this.Calendar1.SelectedDate = pc.Birthday;
         }
      }
   }
}


Write the following handler for the Submit button, for saving the user data into the profile:

protected void btnsubmit_Click(object sender, EventArgs e)
{
   ProfileCommon pc=this.Profile.GetProfile(Profile.UserName);
  
   if (pc != null)
   {
      pc.Name = this.txtname.Text;
      pc.Address.Street = this.txtaddr.Text;
      pc.Address.City = this.txtcity.Text;
      pc.Address.State = this.txtstate.Text;
      pc.Address.Zipcode = this.txtzip.Text;
      pc.Birthday = this.Calendar1.SelectedDate;
     
      pc.Save();
   }
}


When the page is executed for the first time, the user needs to enter the information. However, next time the user details would be automatically loaded.

Attributes for the <add> Element

Apart from the name and type attributes that we have used, there are other attributes to the <add> element. Following table illustrates some of these attributes:

Anonymous Personalization

Anonymous personalization allows the user to personalize the site before identifying themselves. For example, Amazon.com allows the user to add items in the shopping cart before they log in. To enable this feature, the web.config file could be configured as:

<anonymousIdentification enabled ="true" cookieName=".ASPXANONYMOUSUSER"
   cookieTimeout="120000" cookiePath="/" cookieRequiresSSL="false"
   cookieSlidingExpiration="true" cookieprotection="Encryption"
   coolieless="UseDeviceProfile"/>

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



ASPHostPortal.com Announces Umbraco 7.5.6 Hosting Solution

clock December 20, 2016 10:45 by author Dan

ASPHostPortal.com is trusted Windows ASP.NET hosting provider since 2008. They strongly believe in high quality standards and Hence, people will always find their services better than every other host in this industry. They understand the value of time and hence their ordering process is very simple. Now, they offer reliable Umbraco 7.5.6 hosting with good speed and uptime.

Umbraco is easy to learn and use, making it perfect for web designers, developers and content creators alike. People can be up and running in just a few minutes with their simple installer. Either apply one of the included starter kits or seamlessly integrate any designs.

With simple and customisable editing and content creation tools, it's easy to manage and maintain any websites exactly how people want it. Umbraco doesn't dictate how people should work - that should be up to them, not their content management system. Editors have as little or as much freedom as they need. And if you don't like the changes you've made? Simply roll back to a previous version. It's that easy!

ASPHostPortal.com is set up with an aim to serve customers in an excellent manner by providing them quality service. They offer Umbraco 7.5.6 hosting with affordable price, a lot of features, 99.99% uptime guarantee, 24/7 support, and 30 days money back guarantee. Therefore, their focus is always aimed at making sure customers are constantly able to achieve optimal performance and usability with all of the services that they offer. To learn more about their Umbraco 7.5.6 Hosting, please visit http://asphostportal.com/Umbraco-7-Hosting

About ASPHostPortal.com:

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET & Linux Hosting. ASPHostPortal.com has ability to support the latest Microsoft, ASP.NET, and Linux technology, such as: such as: WebMatrix, Web Deploy, Visual Studio, Latest ASP.NET Version, Latest ASP.NET MVC Version, Silverlight and Visual Studio Light Switch, Latest MySql version, Latest PHPMyAdmin, Support PHP, etc. Their service includes shared hosting, reseller hosting, and Sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are at the core of hosting operations to make certain every website and software hosted is so secured and performs at the best possible level.



ASP.NET Hosting - ASPhostPortal.com :: Tips Create User Roles in ASP.NET MVC

clock December 20, 2016 04:54 by author Armend

ASP.NET MVC 5 is the latest update to Microsoft's popular MVC (Model-View-Controller) technology - an established web application framework. MVC enables developers to build dynamic, data-driven web sites. MVC 5 adds sophisticated features like single page applications, mobile optimization, adaptive rendering, and more.

In this article, We'll look into how to create default user roles in ASP.NET MVC 5. Let's begin by establishing where the user role is assigned, and that is the registration stage. In the default template, you have the AccountController that contains a Register action. The default implementation looks like this:

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Register(RegisterModel model)
{
    if (ModelState.IsValid)
    {
        // Attempt to register the user
        try
        {
            WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
            WebSecurity.Login(model.UserName, model.Password);
            return RedirectToAction("Index", "Home");
        }
        catch (MembershipCreateUserException e)
        {
            ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
        }
    }
    // If we got this far, something failed, redisplay form
    return View(model);
}


What's missing here is the role assignment, so let's add that. Right after the CreateUserAndAccount call, we can check whether a specific role exists, and if it is - add the registered user to it. In case the role is new, create it.

if (!Roles.RoleExists("Standard"))
    Roles.CreateRole("Standard");
Roles.AddUserToRole(model.UserName, "Standard");


Here I am working with a role called Standard, but obviously you can use another identifier for it. If you open the database that is carrying the app data, you will notice that there are two new tables introduced in the existing context - Roles and UsersInRoles.

As the data skeleton is established, you can now limit content access based on roles. In views, you could use the Authorize attribute:

[Authorize(Roles = "Admin")]

Or you could check for the role directly:


@if (Roles.GetRolesForUser().Contains("Admin"))
{
}

 

Best ASP.NET MVC Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.

 



ASP.NET Hosting - ASPHostPortal.com :: Working with the panel control ASP.NET

clock December 17, 2016 15:17 by author Dan

According to tutorialspoint website, The Panel control works as a container for other controls on the page. It controls the appearance and visibility of the controls it contains. It also allows generating controls programmatically.

The basic syntax of panel control is as follows:


<asp:Panel ID= "Panel1"  runat = "server">
</asp:Panel>


The Panel control is derived from the WebControl class. Hence it inherits all the properties, methods and events of the same. It does not have any method or event of its own. However it has the following properties of its own:

Working with the Panel Control

Let us start with a simple scrollable panel of specific height and width and a border style. The ScrollBars property is set to both the scrollbars, hence both the scrollbars are rendered.

The source file has the following code for the panel tag:

<asp:Panel ID="Panel1" runat="server" BorderColor="#990000" BorderStyle="Solid"
   Borderstyle="width:1px" Height="116px" ScrollBars="Both" style="width:278px">
  
   This is a scrollable panel.
   <br />
   <br />

   <asp:Button ID="btnpanel" runat="server" Text="Button" style="width:82px" />
</asp:Panel>


The panel is rendered as follows:

Example

The following example demonstrates dynamic content generation. The user provides the number of label controls and textboxes to be generated on the panel. The controls are generated programmatically.

Change the properties of the panel using the properties window. When you select a control on the design view, the properties window displays the properties of that particular control and allows you to make changes without typing.


The source file for the example is as follows:

<form id="form1" runat="server">
   <div>
      <asp:Panel ID="pnldynamic" runat="server" BorderColor="#990000"
         BorderStyle="Solid" Borderstyle="width:1px" Height="150px"  ScrollBars="Auto" style="width:60%" BackColor="#CCCCFF"  Font-Names="Courier" HorizontalAlign="Center">
    
         This panel shows dynamic control generation:
         <br />
         <br />
      </asp:Panel>
   </div>

   <table style="width: 51%;">
      <tr>
         <td class="style2">No of Labels:</td>
         <td class="style1">
            <asp:DropDownList ID="ddllabels" runat="server">
               <asp:ListItem>0</asp:ListItem>
               <asp:ListItem>1</asp:ListItem>
               <asp:ListItem>2</asp:ListItem>
               <asp:ListItem>3</asp:ListItem>
               <asp:ListItem>4</asp:ListItem>
            </asp:DropDownList>
         </td>
      </tr>

      <tr>
         <td class="style2"> </td>
         <td class="style1"> </td>
      </tr>

      <tr>
         <td class="style2">No of Text Boxes :</td>
         <td class="style1">
            <asp:DropDownList ID="ddltextbox" runat="server">
               <asp:ListItem>0</asp:ListItem>
               <asp:ListItem Value="1"></asp:ListItem>
               <asp:ListItem>2</asp:ListItem>
               <asp:ListItem>3</asp:ListItem>
               <asp:ListItem Value="4"></asp:ListItem>
            </asp:DropDownList>
         </td>
      </tr>

      <tr>
         <td class="style2"> </td>
         <td class="style1"> </td>
      </tr>

      <tr>
         <td class="style2">
            <asp:CheckBox ID="chkvisible" runat="server"
               Text="Make the Panel Visible" />
         </td>

         <td class="style1">
            <asp:Button ID="btnrefresh" runat="server" Text="Refresh Panel"
               style="width:129px" />
         </td>
      </tr>
   </table>
</form>


The code behind the Page_Load event is responsible for generating the controls dynamically:

public partial class _Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      //make the panel visible
      pnldynamic.Visible = chkvisible.Checked;

      //generating the lable controls:
      int n = Int32.Parse(ddllabels.SelectedItem.Value);
      for (int i = 1; i <= n; i++)
      {
         Label lbl = new Label();
         lbl.Text = "Label" + (i).ToString();
         pnldynamic.Controls.Add(lbl);
         pnldynamic.Controls.Add(new LiteralControl("<br />"));
      }
     
      //generating the text box controls:

      int m = Int32.Parse(ddltextbox.SelectedItem.Value);
      for (int i = 1; i <= m; i++)
      {
         TextBox txt = new TextBox();
         txt.Text = "Text Box" + (i).ToString();
         pnldynamic.Controls.Add(txt);
         pnldynamic.Controls.Add(new LiteralControl("<br />"));
      }
   }
}


When executed, the panel is rendered as:

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



ASPHostPortal.com Announces Visual Studio 2017 Hosting Solution

clock December 13, 2016 07:24 by author Dan

Established in 2008, ASPHostPortal.com is one of the leading ASP.NET hosting provider offering high quality Visual Studio 2017 Hosting service with premium support. We are using SSD's for storage, which provides much higher performance in terms of I/O and data transfer speed. Every server is equipped with at least 2x Intel Xeon Quad-Core processors and massive amounts of memory. Now, we offer reliable Visual Studio 2017 hosting with uptime guarantee.

Enhancements to code navigation, IntelliSense, refactoring, code fixes, and debugging, saves people time and effort on everyday tasks regardless of language or platform. For teams embracing develops, Visual Studio 2017 streamlines any inner loop and speeds up the code flow with the brand new real time features such as live unit testing and real-time architectural dependency validation.

Visual Studio 2017 is a renewed focus to enhance the efficiency of the fundamental tasks people encounter on a daily basis. From a brand-new lightweight and modular installation tailored to any needs, a faster IDE from startup to shut down, to a new way to view, edit, and debug any code without projects and solutions. Visual Studio 2017 helps people stay focused on the big picture.

ASPHostPortal.com is set up with an aim to serve customers in an excellent manner by providing them quality service. We offer Visual Studio 2017 hosting with affordable price, a lot of features, 99.99% uptime guarantee, 24/7 support, and 30 days money back guarantee. Therefore, our focus is always aimed at making sure customers are constantly able to achieve optimal performance and usability with all of the services that we offer. To learn more about their Visual Studio 2017 Hosting, please visit http://asphostportal.com/Visual-Studio-2017-Hosting

About ASPHostPortal.com:
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET & Linux Hosting. ASPHostPortal.com has ability to support the latest Microsoft, ASP.NET, and Linux technology, such as: such as: WebMatrix, Web Deploy, Visual Studio, Latest ASP.NET Version, Latest ASP.NET MVC Version, Silverlight and Visual Studio Light Switch, Latest MySql version, Latest PHPMyAdmin, Support PHP, etc. Their service includes shared hosting, reseller hosting, and Sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are at the core of hosting operations to make certain every website and software hosted is so secured and performs at the best possible level.



ASP.NET Hosting - ASPHostPortal.com :: 7 Tips for Developing a Secure ASP.NET Web Application

clock December 13, 2016 04:52 by author Armend

7 Tips for Developing a Secure ASP.NET Web Application

As the usage of the internet and the number of web applications over the internet have gone exponentially high there are bad people who continuously work around the clock to hack them. It may be for personal gain or just as an amateur act. Despite the intention of the bad guy the damage caused to the organization hosting the site or its users should be taken into account. As a professional web application developer it is a must to be aware of the best practices to follow in order to make the application more secure. In this article I will be listing and explaining my top 7 tips for developing a secure asp.net application.

Don’t Let Your Users be Victims of Click Jacking

Have you ever thought about someone framing your website onto theirs, making your users to be the victims of click jacking? Yes, the attackers can load your website onto their site in an iframe. They can then skillfully place their transparent controls over your website and fetch the PII information, user credentials, make them perform an unwanted task like exposing their financial information, etc.
In order to prevent that you will have to use a frame busting technique. The following script will not allow your website to be iframed. This can be placed in your master pages.

  •     <script type="text/javascript" language="javascript">
  •         //Check if the top location is same as the current location
  •         if (top.location.hostname != self.location.hostname) {
  •             //If not then set the top to you current
  •             top.location.href = self.location.href;
  •         }
  •     </script>
  • In addition to the above script don’t forget to add the following header, which informs the browser to DENY framing of this website. This is supported in all major browsers except IE versions less than 8.
    The header should be added in the global.asax application start event.

    1. protected void Application_Start(object sender, EventArgs e)
    2. {
    3.             HttpContext.Current.Response.AddHeader("x-frame-options", "DENY");
    4. }
    5.  

     

    In addition to the above script don’t forget to add the following header, which informs the browser to DENY framing of this website. This is supported in all major browsers except IE versions less than 8.
    The header should be added in the global.asax application start event.

    1. protected void Application_Start(object sender, EventArgs e)
    2. {
    3.             HttpContext.Current.Response.AddHeader("x-frame-options", "DENY");
    4. }
    5.  

     

    White List the Request URL

    Though we have many techniques to perform the security preventions inside the application it is most important to prevent the bad data from being entered into your website at the first place. Most attacks happen through the query string values passed through the URL. It is a best security practice to define a common place like an HttpModule to white list the URL, i.e. sanitize the entire URL with a set of white listed characters and drop all the bad ones. It means you will not encourage any other characters apart from a white listed set defined in your application.
    It is important for you to know that black listing is not a foolproof mechanism and it can be broken by the hackers easily.

    Practice of Encoding the Data

    While processing and sending, the data in the response that is fetched from outside the trust boundary should always be encoded. The type of encoding may differ based on the usage of the non-trusted data. For example perform an HtmlEncode for the data that is sent to the client page.

    Label1.Text = Server.HtmlEncode(Request.QueryString["BadValue"]);

     

    Encoding the data will make the XSS scripts inactive and prevent them from being executed. Microsoft has provided the AntiXss library, which provides more sophisticated encoding methods including the JavascriptEncode.

    Using Cookies

    As a web developer you should take utmost care while using cookies, which may open a back door for the hackers to get into your applications. Following are the best practices while using a cookie to store information.
    1. Is your website is hosted under SSL? Then be sure to mark your cookies as secure. This will make them available only in the SSL transmissions.

    1. HttpCookie cookie = new HttpCookie("MySecureCookie");
    2. cookie.Value = "This is a PII information";
    3. cookie.Secure = true;

     

    If your website is not SSL enabled then always encrypt the values using a strong encryption mechanism like AES 256 and then store them in the cookies.

    Secure the Service Calls (WCF / Web Service)

    Are you exposing WCF services through basicHttpBinding? Then think again because the messages transmitted over will be plain text and any intruder will be able to trap the requests and even simulate them easily. Use wsHttpBinding, which will transport the messages in an encrypted format, which makes the life of the intruder hard.
    Though you make lots of protections for your WCF or web services it is a best practice to host the services under an SSL layer.
    Never Deploy the Application with debug=”true”
    It is strongly recommended not to deploy your applications in the production environment with compilation debug=”true” in your web.config. This will result in a big nightmare for performance and security of the application.
    This may leak too much information for the attackers, for example the stack trace in the event of an unhandled exception and the debug trace information. Such exposure of the internals will be good bucks for the attackers.

  • <system.web>
  •         <compilation debug="false" targetFramework="4.0" />
  •     </system.web>
  • Thinking About Turning Off ViewStateMAC?

    Turning off ViewStateMAC will create a security loophole in your asp.net application if you are using Viewstate on your web pages. The intruders will easily be able to intercept, read the 64 bit encoded values and modify them to do some bad things to your website. Having it turned on ensures that the viewstate values are not only encoded but also a cryptographic hash is performed using a secret key.

    1. <pages enableViewStateMac="true"></pages>

     

    I hope this article is useful for the developers who thrive at making their asp.net application an absolutely impossible place for the hackers to deal with.

    Happy reading!

    Best ASP.NET Hosting Recommendation

    ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.

     



    ASP.NET Hosting - ASPHostPortal.com :: How to Configure ASP.NET Core Project

    clock December 9, 2016 10:09 by author Dan

    According to tutorialspoint website about the configuration related to ASP.NET Core project. In Solution Explorer, you will see the Startup.cs file. If you have worked with previous versions of ASP.NET Core, you will probably expect to see a global.asax file, which was one place where you could write codes to execute during startup of a web application.

    • You would also expect to see a web.config file containing all the configuration parameters your application needed to execute.
    • In ASP.NET Core those files are all gone, and instead of configuration and startup code are loaded from Startup.cs.
    • There is a Startup class inside the file and in this class you can configure your application and even configure your configuration sources.

    Here is the default implementation in the Startup.cs file.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;

    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.AspNetCore.Http;

    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Logging; 

    namespace FirstAppDemo {
       public class Startup {
          // This method gets called by the runtime.
          // Use this method to add services to the container.
          // For more information on how to configure your application,
          // visit http://go.microsoft.com/fwlink/?LinkID=398940
          public void ConfigureServices(IServiceCollection services) {
          } 
         
          // This method gets called by the runtime. Use this method to configure
          // the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env,
             ILoggerFactory loggerFactory) {
             loggerFactory.AddConsole(); 
            
             if (env.IsDevelopment()) {
                app.UseDeveloperExceptionPage();
             } 
             app.Run(async (context) => {
                await context.Response.WriteAsync("Hello World!");
             });
          }
       }
    }


    In the Startup class, there are two methods where most of our work will take place. The Configure method of the class is where you build your HTTP processing pipeline.

    • This defines how your application responds to requests. Currently this application can only say Hello World! and if we want the application to behave differently, we will need to change the pipeline around by adding additional code in this Configure method.
    • For example, if we want to serve the static files such as an index.html file, we will need to add some code to the Configure method.
    • You can also have an error page or route requests to an ASP.NET MVC controller; both of these scenarios will also require to do some work in this Configure method.
    • In the Startup class, you will also see the ConfigureServices() method. This helps you configure components for your application.

    Right now, we have a hard-coded string for every response — the Hello World! string. Instead of hard-coding the string, we want to load this string from some component that knows the text that we want to display.

    • This other component might load that text from a database or a web service or a JSON file, it doesn't matter where exactly it is.
    • We will just set up a scenario so that we do not have this hard-coded string.

    In the Solution Explorer, right-click on your project node and select Add → New Item.

    In the left pane, select Installed → Code and then in the middle pane, select the JSON File. Call this file AppSettings.json and click on the Add button as in the above screenshot.

    We can also have our program read the text from the file instead of having the Hello World! String in Startup.cs. Let us add the following code in AppSettings.json file.

    {
       "message": "Hello, World! this message is from configuration file..."
    }


    Now we need to access this message from the Startup.cs file. Here is the implementation of the Startup.cs file which will read the above message from the JSON file.

    using Microsoft.AspNet.Builder;
    using Microsoft.AspNet.Hosting;
    using Microsoft.AspNet.Http;

    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Configuration; 

    namespace FirstAppDemo {
       public class Startup {
          public Startup() {
             var builder = new ConfigurationBuilder()  
                .AddJsonFile("AppSettings.json");
             Configuration = builder.Build();
          } 
          public IConfiguration Configuration { get; set; } 
         
          // This method gets called by the runtime.
          // Use this method to add services to the container.
          // For more information on how to configure your application,
          // visit http://go.microsoft.com/fwlink/?LinkID=398940
          public void ConfigureServices(IServiceCollection services) {
          } 
         
          // This method gets called by the runtime. 
          // Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app) {
             app.UseIISPlatformHandler(); 
             app.Run(async (context) => {
                var msg = Configuration["message"];
                await context.Response.WriteAsync(msg);
             }); 
          } 
           
          // Entry point for the application.
          public static void Main(string[] args) =7gt; WebApplication.Run<Startup>(args);
       }
    }


    Let us now run the application. Once you run the application, it will produce the following output.

    Best ASP.NET Hosting Recommendation

    ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



    ASPHostPortal.com Announces Drupal 8.2.3 Hosting Solution

    clock December 6, 2016 12:23 by author Dan

    ASPHostPortal.com has served people since 2008 and we know how to deliver powerful, fast and reliable Drupal 8.2.3 hosting with the superior customer support. We strive to make sure that people, the customer, have the finest web-hosting experience as possible. Our commitment to excellence in customer support and system performance is truly what sets us apart from the competition. Now, we offer reliable Drupal 8.2.3 hosting with money back guarantee.

    Drupal 8 is the latest, greatest release of the world's most widely used enterprise web CMS. It's fast. Flexible.  Drupal 8 taps into the concentrated innovation from its open source community. People can drive value and streamline your work with new capabilities for successful digital experiences.

    Drupal 8 has something for everyone who supports online content and digital experience at any organization: business decision makers, site administrators, digital marketers, content managers, web developers, technical architects, and IT pros. Drupal 8's core platform has more than 200 new features built in. But it's more than a collection of features; Drupal 8 is a platform you can use to achieve digital success.

    ASPHostPortal.com is set up with an aim to serve customers in an excellent manner by providing us quality service. We offer Drupal 8.2.3 hosting with affordable price, a lot of features, 99.99% uptime guarantee, 24/7 support, and 30 days money back guarantee. Therefore, our focus is always aimed at making sure customers are constantly able to achieve optimal performance and usability with all of the services that we offer. To learn more about our Drupal 8.2.3 Hosting, please visit http://asphostportal.com/Drupal-8-2-3-Hosting.aspx

    About ASPHostPortal.com:
    ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET & Linux Hosting. ASPHostPortal.com has ability to support the latest Microsoft, ASP.NET, and Linux technology, such as: such as: WebMatrix, Web Deploy, Visual Studio, Latest ASP.NET Version, Latest ASP.NET MVC Version, Silverlight and Visual Studio Light Switch, Latest MySql version, Latest PHPMyAdmin, Support PHP, etc. Their service includes shared hosting, reseller hosting, and Sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are at the core of hosting operations to make certain every website and software hosted is so secured and performs at the best possible level.



    ASP.NET Hosting - ASPHostPortal.com :: Repair Dropdown Boxes in ASP.NET Datagrids

    clock December 6, 2016 07:43 by author Armend

    Introduction

    Today, I will explain Step by Step to Repair Dropdown Boxes in ASP.NET Datagrids. Alright, this issue isn't silverlight, yet I did experience it in my day work. Truth be told, I've experienced it a few times, so I thought I would compose it up so I can discover it once more.

     

    Error

    You compose a page that contains an updatable datagrid, which, when in Editmode, contains a dropdown rundown containing lookup things. The Dropdownbox does not populate, and (later when you get it working) the correct listitem is not chosen.

    Cause

    Since the Dropdownbox down not existing when the page loads, there is nothing to tie.

    Step by Step

    You need to append your occasions to some non-standard page occasions to get it to work. The pertinent piece of the .aspx page is underneath (placed this in your datagrid)

    <asp:TemplateColumn HeaderText=”Tactic Category”>

    <HeaderStyle Font-Size=”Large” Font-Bold=”true” />
    <ItemTemplate>
    <%#DataBinder.Eval(Container.DataItem,”TacticCatName”)%>
    </ItemTemplate>
    <EditItemTemplate>
    <%–Notice the GetCat() routine here as the datasource.–%>
    <asp:DropDownList id=”ddTacticCatList” runat=”server” DataSource=”<%# GetCat() %>” DataTextField=”TacticCatName” DataValueField=”TacticCatID”>
    </asp:DropDownList>
    </EditItemTemplate>

    </asp:TemplateColumn>

    Your code-behind page should look like this (in C#)


    private void MainCode()
    {
    string strID = Request.QueryString["id"].ToString();
    //custom code to get the relevant dataset for the entire datgrid
    DataSet ds = LMR.TacticSubCatList(strID);
    //custom code to bind to the datagrid
    Utility.DGDSNullCheck(ds, dgTacticSubCatList, lblTacticSubCatList, “There are no tactic subcategories in the database at this time.”);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    MainCode();
    }
    }

    protected void dgTacticSubCatList_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    //grab the index
    dgTacticSubCatList.EditItemIndex = e.Item.ItemIndex;
    MainCode();
    }

    protected void dgTacticSubCatList_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    //get the id value of the selected datagrid item
    int intTacticSubCatID = (int)dgTacticSubCatList.DataKeys[(int)e.Item.ItemIndex];

    //this gets our textbox, also in the datagrid
    TextBox EditText = null;
    EditText=(TextBox)e.Item.FindControl(“tbTacticSubCatName”);
    string strEditText = Convert.ToString(EditText.Text);

    //get the value of our dropdown list
    DropDownList dd = (DropDownList)e.Item.FindControl(“ddTacticCatList”);
    string strTacticCatID = dd.SelectedValue.ToString();
    //do our database update
    LMR.TacticSubCatEdit(intTacticSubCatID.ToString(),strTacticCatID,strEditText);
    //reset the datagrid
    dgTacticSubCatList.EditItemIndex = -1;
    //give feedback and rebind
    lblFeedback.Text = “Your changes have been applied.”;
    MainCode();
    }

    protected void dgTacticSubCatList_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    dgTacticSubCatList.EditItemIndex = -1;
    MainCode();
    }
    protected DataTable GetCat()
    {
    //here is where we get the dataset to populate the dropdown list – it does have to go in an independant function
    DataSet ds = LMR.TacticCatList();
    return ds.Tables[0];
    }

    protected void dgTacticSubCatList_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
    if (e.Item.ItemType == ListItemType.EditItem)
    {
    //we set the selcted index in the ItemDataBound event
    string strID = Request.QueryString["id"].ToString();
    string strSubCatID = dgTacticSubCatList.DataKeys[(int)e.Item.ItemIndex].ToString();
    Holder.TacticSubCat tsc = LMR.GetTacticSubCat(strSubCatID);
    DropDownList dd = (DropDownList)e.Item.FindControl(“ddTacticCatList”);
    dd.SelectedIndex =dd.Items.IndexOf(dd.Items.FindByValue(strID));
    }
    }

     

    It's as simple as that. Hopefully this article will be usefull for you.

     

    Best ASP.NET Hosting Recommendation

    ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice



    ASP.NET Hosting - ASPHostPortal.com :: How to set Defaultbutton property in ASP.NET

    clock December 2, 2016 07:09 by author Dan

    According to DotNetTricks website, Suppose, you want to press/click submit button on Enter key press or you are trying to post the form on Enter key press. In asp.net, to achieve this functionality we need to set "Defaultbutton" property either in Form or in panel.

    Form DefaultButton Property

        <form id="form1" runat="server" defaultbutton="btnSubmit">
        <div>
        <asp:TextBox ID="txtUserID" runat="server"/> <asp:TextBox ID="txtUserpwd" runat="server"/> <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit _Click" Text="Submit"/>
        </div>
        </form>


    Panel DefaultButton Property

        <asp:Panel ID="Panel1" runat="server" defaultbutton="btnSubmit">
        <div>
        <asp:TextBox ID="txtUserID" runat="server"/> <asp:TextBox ID="txtUserpwd" runat="server"/> <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit _Click" Text="Submit"/>
        </div>
        </asp:Panel >


    Note

    • We specify the defaultbutton property at the Form level in the form tag when there is only one Submit Button for post back.
    • We specify the defaultbutton property at the Panel level in the Panel tag when there are multiple Submit Button for post back.

    Summary

    In this article I try to explain the default submit behavior of form and panel. I hope you will refer this article for your need.

    Best ASP.NET Hosting Recommendation

    ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



    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