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 5 Hosting - ASPHostPortal.com :: Cookie Based Authentication in ASP.NET 5

clock July 30, 2015 06:27 by author Dan

This post is about cookie based authentication in ASP.NET 5. I am implementing a cookie authentication in ASP.NET MVC application. Similar to other middleware components in ASP.NET, Cookie Authentication is also a middleware component, which you need to plug into ASP.NET pipeline.

For implementing cookie authentication, you require reference of Cookie middleware, here is the project.json file.

{
    "dependencies": {
        "Microsoft.AspNet.Diagnostics": "1.0.0-beta1",
        "Microsoft.AspNet.Hosting": "1.0.0-beta1",
        "Microsoft.AspNet.Mvc": "6.0.0-beta1",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta1",
        "Microsoft.AspNet.Security": "1.0.0-beta1",
        "Microsoft.AspNet.Security.Cookies": "1.0.0-beta1",
        "Microsoft.AspNet.StaticFiles": "1.0.0-beta1",
    },
    "commands": {
        "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001"
    },
     "frameworks": {
        "aspnet50": {}
  }
}

All the components used in this project are available in ASP.NET Core Framework as well.

Now you need to plug the Cookie authentication module to use in ASP.NET pipeline, you can do this via Startup.cs file.

public class Startup
{
    public void Configure(IApplicationBuilder app)
    {
        app.UseErrorPage();
 
        app.UseServices(services =>
        {
            services.AddMvc();
        });
     
        app.UseCookieAuthentication(options => {
            options.LoginPath = new PathString("/Home/Login");
        });
        app.UseMvc();                       
    }       
}

Now, you need to apply the Authorize filter to protect resources, I am applying it in the class level. When there is a unauthorized request to such resource, filter returns 401 and the cookie middleware redirects to /Home/Login.

Note: You need to set the LoginPath property explicitly, otherwise it may not redirect.

[Authorize]
public class HomeController : Controller
{
    public IActionResult Index()
    {
        return View();
    }
}

And here is the Login action method, this code is for illustration purpose only, I not validating against database, if username and password matches the hard coded credentials, identity is established with that username.

[AllowAnonymous]
public IActionResult Login()
{
    return View();
}
 
[HttpPost, AllowAnonymous]
public IActionResult Login(User user)
{
    if(user.UserName == "admin" && user.Password == "Password")
    {
        var claims = new[]
        {
            new Claim("name", user.UserName)
        };
        var identity = new ClaimsIdentity(claims,
            CookieAuthenticationDefaults.AuthenticationType);
        Context.Response.SignIn(identity);
 
        return Redirect("~/");
    }
    else
    {
        ModelState.AddModelError("LogOnError",
            "The user name or password provided is incorrect.");
    }
    return View(user);
}
 
public IActionResult Logout()
{
    Context.Response.SignOut
    (CookieAuthenticationDefaults.AuthenticationType);
    return View("Login");
}

And here is the Login view

@using(Html.BeginForm())
{
    @Html.LabelFor(model => model.UserName)
    @Html.EditorFor(model => model.UserName)
    @Html.LabelFor(model => model.Password)
    @Html.PasswordFor(model => model.Password)
    <input type="submit" value="Sign In" />
    <br/>
    @Html.ValidationMessage("LogOnError")
}

To verify the implementation, install the required packages using kpm restore command, once it finishes, execute k web command. If web server is started, browse http://localhost:5001/, which will redirect to /Home/Login page, where you can enter the credentials, you will redirect back to /Home/Index page.

Best ASP.NET 5 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 MVC 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 :: Remote Web Access Unexpected Error

clock July 13, 2015 06:14 by author Dan

We occasionally come across scenarios where memory consumption on an SBS Server increases and this may cause the server to run slow.
Additionally, some of the services/features may stop working correctly.

You may find that trying to connect to computers or accessing shares from within RWA may fail with an error message similar to the one below:

Another symptom might be that you try clicking on a gadget in RWA and nothing happens.

If you check the event logs, you will find this warning:

Log Name: Application
Source: ASP.NET 4.0.30319.0
Date: 9/17/2013 15:31:28
Event ID: 1309
Task Category: Web Event
Level: Warning
Keywords: Classic
User: N/A
Computer: SBS.Contoso.local
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 9/17/2013 15:31:28 Event time (UTC): 9/17/2013 13:31:28 Event ID: 401c8120945a4115abb39de75d347aba
Event sequence: 5
Event occurrence: 1
Event detail code: 0

Application information:

    Application domain: /LM/W3SVC/1/ROOT/Remote-1-130099878420126008
    Trust level: Full
    Application Virtual Path: /Remote
    Application Path: C:\Program Files\Windows Small Business Server\Bin\WebApp\RemoteAccess\
    Machine name: SBS

Process information:

    Process ID: 5100
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:

    Exception type: InsufficientMemoryException
    Exception message: Memory gates checking failed because the free memory (369917952 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.
   at System.ServiceModel.Activation.ServiceMemoryGates.Check(Int32 minFreeMemoryPercentage, Boolean throwOnLowMemory, UInt64& availableMemoryBytes)
  at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CheckMemoryCloseIdleServices(EventTraceActivity eventTraceActivity)
 at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)


There could be multiple contributors to the above problem. If you have applied .NET Framework 4.5.1 recently, you can work around this issue by modifying the Remote Web Access web.config file using the following steps:

  • Open web.config file located at: “%ProgramFiles%\Windows Small Business Server\Bin\WebApp\RemoteAccess”.
  • Search in Web.config for "<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />", change this line to "<serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="0"/>"
  • Save changes and close the file.
  • Run IISRESET from an elevated Command Prompt window


You should not uninstall any versions of the .NET Framework that are installed on your computer, because an application in use may depend on a specific version of the .NET Framework. For more information, see The .NET Framework for Users in the Getting Started guide.

Note: If you don't have .NET Framework 4.5.1 installed and are still running in the issue described above, you may need to analyze the memory usage of different processes running on the server and fine tune them. In such a scenario, normal performance troubleshooting steps apply. Capturing a Performance Monitor log and comparing it with baseline performance throughput should be the right way to move forward.

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 MVC 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 7.38 Hosting Solution

clock July 9, 2015 09:30 by author Dan

Hosting is one of the best way to get connected to the World Wide Web. The best thing or we can say it technology is the internet. The peoples’ lives are depending on the internet and the people are taking the full benefit from the internet. The boon of the internet is the online business, one can spread his or her business in all over the world while being in a single location. In the online business, many companies are offering their service, so that the business owner can easily achieve the success in business. ASPHostPortal.com is reliable and honest ASP.NET hosting provider for you. Today, they offer Drupal 7.38 hosting with fast support and fast network.

Drupal web design is the first choice of many for a number of reasons. The Drupal content management system offers an ever-expanding, free, buildable, customizable, and constantly updated high-quality framework for websites and web applications. But the very things that make Drupal design a premium choice are the same things that can sometimes be its downfall for less experienced website owners and designers. Nevertheless, it is easy to access the support of Drupal web design experts and enjoy the many benefits a Drupal website has to offer.

Like all software programs, Drupal core software and Drupal modules are subject to some bugs and non-compatibility issues, as well as other issues that face any software program. Often, because of the many expert minds behind Drupal programs, these problems are minimal, but they are there. The Drupal CMS was and is developed by the people who use it. That means that there is a never-ending supply of Drupal web design experts using and modifying the program. The best of those modifications are added to the core or offered as add-on Drupal modules.

ASPHostPortal.com provides premium Drupal 7.38 hosting plans on high performance servers and high-speed internet connection in the world. Every server is equipped with at least 2x Intel Xeon Quad-Core processors and massive amounts of memory. They are using SSD's for storage, which provides much higher performance in terms of I/O and data transfer speed. The servers are connected to the network using multiple 1Gbps ports (bond network). To learn more about Drupal 7.38 Hosting, please visit http://asphostportal.com/Drupal-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, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, Latest MySql version, Latest PHPMyAdmin, Support PHP 5.x, etc. Their service include shared hosting, reseller hosting, and sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are on 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 :: 4 Steps to designate appropriate permissions to App_Data folder of WebMail Pro ASP.NET

clock July 3, 2015 06:07 by author Dan

If you got one of the following errors during WebMail Pro ASP.NET installation:

Creating/deleting folders Error, can't create folders in the data folder.
Creating/deleting files Error, can't create files in the data folder.
Error, can't read/write "C:\Inetpub\wwwroot\WebMailPro\App_Data\settings\*.xml" file.

This means WebMail Pro ASP.NET doesn't have permissions enough to read/write contents of App_Data subfolder.

Note: In this article, we assume your WebMail Pro ASP.NET is deployed to C:\Inetpub\wwwroot\WebMailPro\ folder, but if you've deployed it to another folder, you should take this into account when looking at the paths here.

To resolve the issue, you should grant Full Control permission to ASPNET, NETWORK SERVICE and Internet Guest Account system accounts over App_Data folder:

1. In Windows Explorer, go to C:\Inetpub\wwwroot\WebMailPro\ folder, right-click App_Data folder and choose Properties:

2. In General tab, make sure "Read-only" option is not set:

3. In Security tab, gran "Full Control" permission to ASPNET, NETWORK SERVICE and Internet Guest Account accounts:

4. Click OK. Now, WebMail Pro ASP.NET should have enough permissions to read/write files and folders in the App_Data folder.

Note: If you're installing WebMail Pro ASP.NET to a shared hosting, you'll be unable to assign permissions on your server via Windows Explorer as shown at the screenshots above. However, the control panel provided by your hosting should allow you to do the same. Please refer to your control panel documentation to learn how to do that or ask your hosting provider to assign the permissions 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 MVC 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