European ASP.NET 4.5 Hosting BLOG

BLOG about ASP.NET 4, ASP.NET 4.5 Hosting and Its Technology - Dedicated to European Windows Hosting Customer

ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: Start Using HTTP Handlers In ASP.NET

clock September 19, 2018 11:48 by author Peter

First, let me explain the main purpose of using HTTPHandler. Sometimes you need to handle a specific request separately using a different method from that of a normal request. This article will explain HTTP Handler in a simple way. Let’s begin:
How can you handle any incoming HTTP request with a path “AllUsers/User.gif” by returning “Hello From HTTP Handler”.

  • Create a class file --  it could be MyHttpHandler.cs
  • Let MyHttpHandler class inherit from IhttpHandler Interface.
  • In MyHttpHandler class, implement all the methods which are found in IhttpHandler Interface.

You should do the following,
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
namespace MyProject { 
    public class MyHttpHandler: IHttpHandler { 
        public bool IsReusable { 
            get { 
                return true; 
            } 
        } 
        public void ProcessRequest(HttpContext context) { 
            HttpResponse response = context.Response; 
            response.Write("Hello From Http Handler"); 
        } 
    } 


The next step is to register the http handler in the web.config,

<httpHandlers> 
   <add verb="*" path="AllUsers/User.gif" type="MyProject.MyHttpHandler,MyProject"/> 
</httpHandlers> 


The above code (point 4) should be added as a child of <system.web>

That's all. Now HTTP Handler is ready

Section2
When using HTTP Handler with either MVC or WEB API, you will get the following error:


Because each MVC and WEB API are using routing to access methods within the controller, they will search the path and find that it is not found. To solve this problem you have two choices:

The first one is,

  • Create a class file --  it could be MyRouteHandler.cs
  • Let MyRouteHandlerclass inherit from IRouteHandlerInterface.
  • In MyRouteHandler class, implement all the methods which are found in IRouteHandlerInterface and return the MyHttpHandlerwhich are created in the previous section.

You should do the following,
public class MyRouteHandler: IRouteHandler { 
    public IHttpHandler GetHttpHandler(RequestContext requestContext) { 
        return new MyHttpHandler(); 
    } 


In RouteConfig class which is related to MVC and WEP API and responsible for requests routing, add the following line code to RegisterRoutes method and before the Default MapRoute.
routes.Add(new Route("AllUsers/User.gif", new MyRouteHandler())); 

Drop the HTTP Handler registration from web.config, since calling HTTP Handler will be from RegisterRoutes method.

The Second Solution Is:

Let us go back to section 1. It is a straightforward solution: In RouteConfig class which is related to MVC and WEP API and responsible for requests routing, add the following line of code to the RegisterRoutes method and before the Default MapRoute.
routes.IgnoreRoute("AllUsers/User.gif"); 

That's it.

Note
If you want to Handle all HTTP requests which have a specific extentaion such as gif you can using the following in web.config.
<httpHandlers> 
   <add verb="*" path="*.gif" type="MyProject.MyHttpHandler,MyProject"/> 
</httpHandlers> 

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: How to Unloading Assemblies in C#?

clock September 12, 2018 08:06 by author Peter

If you've created an Application Domain and want to unload all the assemblies loaded within, there is no way to unload Assembly themselves. But you can unload Application Domain you've just created.
 
In addition to that one;
You cannot unload the default Application Domain CLR created on its own. And unloading can differ from the assemblies being used and the unload events these assemblies have. It can take some time.
 
To Unload an Application Domain all you need to do is calling Unload function.
 
A sample code can help you understand:
    AppDomain myDom=AppDomain.Create("Ibrahims Domain"); 
    //Here assuming you loaded your assemblies 
    //To unload AppDomain call Unload Function 
    AppDomain.Unload(myDom); 
    // The Application Domain we've just created is now no more as the assemblies with it. 


After Unloading Application Domain object, we've also unloaded all the assemblies loaded within.

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.

 



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: How to Cross Domain ASP.NET Web API Calling Using jQuery AJAX ?

clock September 5, 2018 13:11 by author Peter

If we have made a Restful API utilizing the ASP.NET Core 2.2.1 Web API and if your API is in one space and the UI is in an alternate area then you may get problem because of cross-domain issues. And here is the way:

  • OPTIONS http://localhost:5000/api/ 404 (Not Found).XMLHttpRequest cannot load http://localhost:5000/api/.
  • No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:54317' is therefore not allowed access. The response had HTTP status code 404.

As it were you can't make a call to the WebAPI by means of your front end that is facilitated on an alternate domain.
So you must utilization JSONP to get information utilizing using AJAX, not by JSON.  To attain to this objective you have to introduce JsonpMediaTypeFormatter. For introducing the JsonpMediaTypeFormatter in Visual Studio, seek JsonpMediaTypeFormatter in "Manage NuGet Packages" and install it.

Next, you can see in your project references that a new DLL was added. WebApiContrib.Formatting.Jsonp.dll

To use this DLL you need to change in the Application_Start() method in the Global.asax.cs file.
using WebApiContrib.Formatting.Jsonp;   
using System.Net.Http.Formatting;   

GlobalConfiguration.Configuration.Formatters.Clear();   GlobalConfiguration.Configuration.Formatters.Add(new JsonpMediaTypeFormatter(new JsonMediaTypeFormatter())); 

You also can use JsonMediaTypeFormatter code, you should write this code in the App_Start folder & register the following code in Application_Start().
JsonMediaTypeFormatter code:
    using System;   
    using System.Collections.Generic;   
    using System.Linq;   
    using System.Web;   
    using System.Net.Http.Formatting;   
    using System.Net.Http.Headers;   
    using System.Net.Http;   
    using Newtonsoft.Json.Converters;   
    using System.IO;   
    using System.Net;   
    using System.Threading.Tasks;   
    namespace WebAPI   
    {   
        /// <summary>   
        /// Handles JsonP requests when requests are fired with text/javascript   
        /// </summary>   
        public class JsonpFormatter : JsonMediaTypeFormatter   
        {   
            public JsonpFormatter()   
            {   
                SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));   
                SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/javascript"));           
                JsonpParameterName = "callback";   
            }   
            /// <summary>   
            ///  Name of the query string parameter to look for   
            ///  the jsonp function name   
            /// </summary>   
           public string JsonpParameterName { get; set; }   
           /// <summary>   
            /// Captured name of the Jsonp function that the JSON call   
            /// is wrapped in. Set in GetPerRequestFormatter Instance   
            /// </summary>   
            private string JsonpCallbackFunction;
            public override bool CanWriteType(Type type)   
            {   
                return true;   
            }           
            /// <summary>   
            /// Override this method to capture the Request object   
            /// </summary>   
            /// <param name="type"></param>   
            /// <param name="request"></param>   
            /// <param name="mediaType"></param>   
            /// <returns></returns>   
            public override MediaTypeFormatter GetPerRequestFormatterInstance(Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType)   
            {   
                var formatter = new JsonpFormatter()   
                {   
                    JsonpCallbackFunction = GetJsonCallbackFunction(request)   
                };   
               // this doesn't work unfortunately   
                //formatter.SerializerSettings = GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings;   
                // You have to reapply any JSON.NET default serializer Customizations here       
                formatter.SerializerSettings.Converters.Add(new StringEnumConverter());   
                formatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;           
                return formatter;   
            }                   
           public override Task WriteToStreamAsync(Type type, object value,   
                                            Stream stream,   
                                            HttpContent content,   
                                            TransportContext transportContext)   
            {   
                if (string.IsNullOrEmpty(JsonpCallbackFunction))   
                    return base.WriteToStreamAsync(type, value, stream, content, transportContext);   
                        StreamWriter writer = null;           
                // write the pre-amble   
                try   
                {   
                    writer = new StreamWriter(stream);   
                    writer.Write(JsonpCallbackFunction + "(");   
                    writer.Flush();   
                }   
                catch (Exception ex)   
                {   
                    try   
                    {   
                        if (writer != null)   
                            writer.Dispose();   
                    }   
                   catch { }           
                    var tcs = new TaskCompletionSource<object>();   
                    tcs.SetException(ex);   
                    return tcs.Task;   
                }           
                return base.WriteToStreamAsync(type, value, stream, content, transportContext)   
                           .ContinueWith(innerTask =>   
                           {   
                               if (innerTask.Status == TaskStatus.RanToCompletion)   
                               {   
                                   writer.Write(")");   
                                   writer.Flush();   
                               }   
                               writer.Dispose();   
                               return innerTask;   
                           }, TaskContinuationOptions.ExecuteSynchronously)   
                                .Unwrap();   
            }   
                    /// <summary>   
            /// Retrieves the Jsonp Callback function   
            /// from the query string   
           /// </summary>   
           /// <returns></returns>   
            private string GetJsonCallbackFunction(HttpRequestMessage request)   
            {   
                if (request.Method != HttpMethod.Get)   
                    return null;   
                        var query = HttpUtility.ParseQueryString(request.RequestUri.Query);   
                var queryVal = query[this.JsonpParameterName];   
                        if (string.IsNullOrEmpty(queryVal))   
                    return null;           
                return queryVal;   
            }   
        }   
    } 

Next step, use the following code to make change in the Application_Start() method in the Global.asax.cs file.
GlobalConfiguration.Configuration.Formatters.Insert(0, new WebAPI.JsonpFormatter());


jQuery code to use the Web API:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>   
    <script language="javascript" type="text/javascript">   
        function GetInformation() {   
            var apiServicePath = "http://localhost:5000/api/";   
            jQuery.ajax({   
                crossDomain: true,  
                dataType: "jsonp",   
                url: apiServicePath + "test/GetInformation",   
                async: false,   
                context: document.body   
            }).done(function (data) {   
                alert("Done");   
            });   
        };   
    </script> 

 

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.

 



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: Mapping Similar Objects In ASP.NET Core 2.0

clock August 20, 2018 11:29 by author Peter

This post is about Automapper. As its name suggests, it will do some sort of mapping. Now, the question is, what sort of mapping? Well, this mapping is all about mapping the properties of two objects with each other. If you have worked on MVC, you must have come across the scenario, where the situation demands you to map properties of the model with the properties of ViewModel. Isn't it a common scenario? So, one way to achieve this is to map each and every property manually with a lot of code, which in turn become very tedious when there are many properties of an object. Another major disadvantage of this approach is it's error-prone.

Hence, Automapper came to rescue. Automapper is an object to object mapping which reduces the manual effort of mapping each property of a class with the same properties of another class. So, let’s start by writing some code and see how it works.

Step 1
First step is to add the required dependency. This can be done either by using UI or by using Nuget package console,

Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection 
if you are using console to add dependency, then on successful installation of the package, the below message will be shown,


Step 2
Get ready with classes which are to be mapped. Here in this case, we have one model class and one ViewModel class as shown below,
public class Contact 
    { 
        public string Name { get; set; } 
        public string SecurityNumber { get; set; } 
        public string Address { get; set; } 
    } 


ContactViewModel

public class ContactViewModel 
    { 
        public string Name { get; set; } 
        public string SecurityNumber { get; set; } 
        public string City { get; set; } 
        public string State { get; set; } 
    } 


Step 3
Create a class which will take care of all the mappings as shown below, by inheriting the profile which is defined in Automapper namespace,
public class MappingEntity:Profile 
    { 
        public MappingEntity() 
        { 
            CreateMap<ContactViewModel, Contact>(); 
        } 
    } 


Step 4
Register this MappingEntity class in Startup class under ConfigureServices method as shown below,
public void ConfigureServices(IServiceCollection services) 
        { 
            services.AddMvc(); 
            services.AddAutoMapper(x => x.AddProfile(new MappingEntity())); 
        } 


Step 5
Final step is to do the changes in Controller class to accomodate this mapping.
public class HomeController : Controller 
   { 
       private readonly IMapper _mapper; 
       public HomeController(IMapper mapper) 
       { 
           _mapper = mapper; 
       } 
 
       public IActionResult Index(ContactViewModel vm) 
       { 
           var contact = _mapper.Map<Contact>(vm); 
           return View(); 
       } 
 
    ... 
  } 

Now, as per the business requirement, the contact object declared in line number 11 can be used. That's all about automapping.

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: Using WebApiClient To Call REST APIs In .NET Core

clock August 15, 2018 11:14 by author Peter

In this article, we will discuss an easy way to call our REST APIs in .NET Core. When we call other APIs in .NET Core, HttpClient will be the first choice. And most of us will create a wrapper to make it easy to use. There are many libraries that are based on HttpClient which help us to call REST APIs.

In this article, I will use WebApiClient.

WebApiClient
WebApiClient is an awesome project which help us to call HTTP(S) APIs. For more information, please visit its GITHUB page,

Here I will use WebApiClient.JIT to demonstrate how to use. Let's begin!

Create Some APIs

Here I use ASP.NET Core WebAPI to creat some RESTful APIs.
    [Route("api/[controller]")] 
    public class PersonsController : Controller 
    { 
        // GET: api/persons 
        [HttpGet] 
        public IEnumerable<Person> Get() 
        { 
            return new List<Person> 
            { 
                new Person{Id = 1 , Name = "stewart"}, 
                new Person{Id = 2 , Name = "peter"} 
            }; 
        } 
     
        // GET api/persons/5 
        [HttpGet("{id}")] 
        public Person Get(int id) 
        { 
            return new Person { Id = id, Name = "name" }; 
        } 
     
        // POST api/persons 
        [HttpPost] 
        public Person Post([FromBody]Person person) 
        { 
            if (person == null) return new Person(); 
     
            return new Person { Id = person.Id, Name = person.Name }; 
        } 
     
        // PUT api/persons/ 
        [HttpPut] 
        public string Put([FromBody]int id) 
        { 
            return $"put {id}"; 
        } 
     
        // DELETE api/persons/5 
        [HttpDelete("{id}")] 
        public string Delete(int id) 
        { 
            return $"del {id}"; 
        } 
    } 


Interface Declaration

Create an interface named IPersonApiClient which inherit from IHttpApiClient.
    public interface IPersonApiClient : IHttpApiClient { } 

Add some methods that need to call APIs.
Every method must have a HTTP attribute that provides the request method and relative URL. The return type should be ITask<T>.
    [HttpGet("/api/persons")]   
    ITask<List<Person>> GetPersonsAsync();   

A request URL can be updated dynamically using replacement blocks and parameters on the method. A replacement block is an alphanumeric string surrounded by { and }.
    [HttpGet("/api/persons/{id}")] 
    ITask<Person> GetPersonAsync(int id); 


When our requst parameters should in request body, we can use some attributes to specify the content, such as JsonContent, FormContent .etc.
    [HttpPost("/api/persons")] 
    ITask<Person> AddPersonAsync([JsonContent]Person person);  


The following code demonstrates the basic usage.
    public interface IPersonApiClient : IHttpApiClient 
    { 
        [HttpGet("/api/persons")] 
        ITask<List<Person>> GetPersonsAsync(); 
     
        [HttpGet("/api/persons/{id}")] 
        ITask<Person> GetPersonAsync(int id); 
     
        [HttpPost("/api/persons")] 
        ITask<Person> AddPersonAsync([JsonContent]Person person); 
     
        [HttpPut("/api/persons")] 
        ITask<string> EditPersonAsync([JsonContent]int id); 
     
        [HttpDelete("/api/persons/{id}")] 
        ITask<string> DeletePersonAsync(int id); 
    } 


The next step is how to retrieve the response of the request.
Retrieving Response

We should create a client first. After creating , what we need to do is call the methods we declared in the interface.

    //specify the config 
    var config = new HttpApiConfig 
    {                 
        HttpHost = new Uri("http://localhost:9999"), 
    }; 
     
    var client = HttpApiClient.Create<IPersonApiClient>(config); 
     
    var persons = await client.GetPersonsAsync(); 
     
    Console.WriteLine("GetPersonsAsync result:"); 
    foreach (var item in persons) 
    { 
        Console.WriteLine($"{item.Id}-{item.Name}"); 
    } 
     
    var person = await client.GetPersonAsync(1000); 
    Console.WriteLine("GetPersonAsync result:"); 
    Console.WriteLine($"{person.Id}-{person.Name}"); 
     
     
    var newPerson = new Person { Id = 999, Name = "999" }; 
    var postResult = await client.AddPersonAsync(newPerson); 
    Console.WriteLine("AddPersonAsync result:"); 
    Console.WriteLine($"{postResult.Id}-{postResult.Name}"); 
     
     
    var editResult = await client.EditPersonAsync(1); 
    Console.WriteLine("EditPersonAsync result:"); 
    Console.WriteLine($"{editResult}"); 
     
    var delResult = await client.DeletePersonAsync(1); 
    Console.WriteLine("DeletePersonAsync result:"); 
    Console.WriteLine($"{delResult}");

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.

 



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: How To Create And Download Zipped Files In .NET?

clock August 13, 2018 12:12 by author Peter

Have you ever encountered a scenario when you have to download a few files zipped and compressed? Few developments involving the manipulation of documents and its management would require this. There are a lot of packages out in the market. Here, in this article, I would be sharing the use of DotNetZip package used to zip, unzip & compress files using C#, VB.NET, & any .NET language.

Once downloaded, it's all set to use the DotNetzip package to start zipping the files and compressing them. For the files to be zipped, here I will be using the file path and select each file to be zipped. Here also, we will see how a file is created on the fly (a PDF using Rotativa) is saved in the same folder and zipped.

File created on the fly using Rotativa
var pdfResult = new Rotativa.PartialViewAsPdf("~/Template.cshtml", model) //This is HTML that would be generated as PDF 

    FileName = "Template.pdf" 
}; 
var resultSet = pdfResult.BuildPdf(ControllerContext); 
if (resultSet != null) { 
    string path = Path.Combine(Server.MapPath(subPath)); 
    FileStream fs = new FileStream(path + ".pdf", FileMode.Create, FileAccess.ReadWrite); 
    BinaryWriter bw = new BinaryWriter(fs); 
    bw.Write(resultSet); 
    bw.Close(); 


The above code snippet is generating a PDF using a cshtml Razor View page using Rotativa Using Rotativa Best to follow the mentioned article for more information to generate PDF using Rotativa using MVC. Let's look at the code snippet for zipping.
using(ZipFile zipFile = new ZipFile()) { 
    //Get all filepath from folder 
    String[] files = Directory.GetFiles(Server.MapPath("/")); 
    string fileUniqueName = "Template" 
    foreach(string file in files) { 
        if (file.Contains(fileUniqueName.ToString())) { 
            zipFile.AddFile(file, @ "TemplateDocs_" + DateTime.Now); 
            //Adding files from filepath into Zip 
        } 
    } 
    Response.ClearContent(); 
    Response.ClearHeaders(); 
    //Set zip file name 
    Response.AppendHeader("content-disposition", "attachment; filename=TemplatedDocuments.zip"); 
    zipFile.CompressionMethod = CompressionMethod.BZip2; 
    zipFile.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression; 
    //Save the zip content in output stream 
    zipFile.Save(outputStream); 

//Set the cursor to start position 
outputStream.Position = 0; 
String[] filesToDelete = Directory.GetFiles(Server.MapPath("/")); 
foreach(string file in filesToDelete) { 
    if (file.Contains(fileUniqueName.ToString())) { 
        FileInfo fi = new FileInfo(file); 
        fi.Delete(); 
    } 

return new FileStreamResult(outputStream, fileType); 

The above snippet is just required to start zipping and compressing the files. As you can see using block for the ZipFile is created with instantiation of its object.

Then, the files present under the path are navigated using Server.MapPath(""), Once the path is set, the files if with some unique string character in the filename needs to be searched and only zipped, is set to a variable.

Then each file is looped through and added to the ZipFile object, here zipFile.AddFiles(file, ZippedFolderName); ZipFolderName here is the name you set for the folder having all the files after extraction.

There are three compression levels for the ZipFile an enum which describes through code as below,
// 
// Summary: 
// The method of compression to use for a particular ZipEntry. 
// 
// Remarks: 
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT describes a number of 
// distinct cmopression methods that can be used within a zip file. DotNetZip supports 
// a subset of them. 
public enum CompressionMethod { 
    // 
    // Summary: 
    // No compression at all. For COM environments, the value is 0 (zero). 
    None = 0, 
        // 
        // Summary: 
        // DEFLATE compression, as described in http://www.ietf.org/rfc/rfc1951.txt. This 
        // is the "normal" compression used in zip files. For COM environments, the value 
        // is 8. 
        Deflate = 8, 
        // 
        // Summary: 
        // BZip2 compression, a compression algorithm developed by Julian Seward. For COM 
        // environments, the value is 12. 
        BZip2 = 12 


The above are the three algorithms used. I personally have used only BZip2 based on few good reviews. Once compressed and all files inserted into the folder, the zipped folder is ready to be downloaded using the FileStreamResult in MVC action. This is the simple explanation and the code snippet for the Zip file concept. This is simple and really handy to be used and it also provides the compression algorithms which are good to go with.

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: Deleting Files With Events

clock August 8, 2018 09:12 by author Peter

While working on the dotNetTips Dev Cleaner utility, I wanted to make the deletion of files even faster. While writing this utility I found and worked on speed issues, almost all relating to updating the user interface. So to decouple the deleting from the UI, I decided to add a new feature to the dotNetTips.Utility open source project.

Processor Class
I added a new class in the dotNetTips.Utility.IO namespace called Processor. The purpose of this class is to copy, move and delete files while firing events that can be used to update the UI. Unlike other methods I have used in other frameworks if an exception occurs, it fires an event and keeps processing.

First I created the event,
public event EventHandler<ProgressEventArgs> Processed; 
 
protected virtual void OnProcessed(ProgressEventArgs e) 

EventHandler<ProgressEventArgs> processedEvent = this.ProcessedEvent; 
if (processedEvent != null) 

processedEvent(this, e); 

}  

//The event above is called by the code below: 

public int DeleteFiles(IEnumerable<FileInfo> files) 

    Encapsulation.TryValidateParam(files, "files", ""); 
    int result = 0; 
    IEnumerator<FileInfo> enumerator; 
    try 
    { 
        enumerator = files.AsParallel<FileInfo>().GetEnumerator(); 
        while (enumerator.MoveNext()) 
        { 
            FileInfo current = enumerator.Current; 
            if (current.Exists) 
            { 
                try 
                { 
                    current.Delete(); 
                    result++; 
                    ProgressEventArgs e = new ProgressEventArgs(); 
                    e.Name = current.FullName; 
                    e.ProgressState = ProgressState.Deleted; 
                    e.Size = current.Length; 
                    this.OnProcessed(e); 
                    continue; 
                } 
                catch (Exception ex) 
                { 
                    ProjectData.SetProjectError(ex); 
                    ProgressEventArgs e1 = new ProgressEventArgs(); 
                    e1.Name = current.FullName; 
                    e1.ProgressState = ProgressState.Error; 
                    e1.Size = current.Length; 
                    e1.Message = ex.Message; 
                    this.OnProcessed(e1); 
                    ProjectData.ClearProjectError(); 
                    continue; 
                } 
            } 

            ProgressEventArgs e2 = new ProgressEventArgs(); 
            e2.Name = current.FullName; 
            e2.ProgressState = ProgressState.Error; 
            e2.Size = current.Length; 
            e2.Message = Resources.FileNotFound; 
            this.OnProcessed(e2); 
        } 
    } 
    finally 
    { 
        if (enumerator != null) 
        { 
            enumerator.Dispose(); 
        } 
    } 

    return result; 


This new class helped my utility go from deleting 1K files per second to up to around 2K per second!

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.

 



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: How To Create And Download Zipped Files In .NET?

clock August 6, 2018 11:07 by author Peter

Have you ever encountered a scenario when you have to download a few files zipped and compressed? Few developments involving the manipulation of documents and its management would require this. There are a lot of packages out in the market. Here, in this article, I would be sharing the use of DotNetZip package used to zip, unzip & compress files using C#, VB.NET, & any .NET language.

Download the DotNetzip package from NuGet package.

Once downloaded, it's all set to use the DotNetzip package to start zipping the files and compressing them. For the files to be zipped, here I will be using the file path and select each file to be zipped. Here also, we will see how a file is created on the fly (a PDF using Rotativa) is saved in the same folder and zipped.

File created on the fly using Rotativa
var pdfResult = new Rotativa.PartialViewAsPdf("~/Template.cshtml", model) //This is HTML that would be generated as PDF  
{  
    FileName = "Template.pdf"  
};  
var resultSet = pdfResult.BuildPdf(ControllerContext);  
if (resultSet != null) {  
    string path = Path.Combine(Server.MapPath(subPath));  
    FileStream fs = new FileStream(path + ".pdf", FileMode.Create, FileAccess.ReadWrite);  
    BinaryWriter bw = new BinaryWriter(fs);  
    bw.Write(resultSet);  
    bw.Close();  
}  


The above code snippet is generating a PDF using a cshtml Razor View page using Rotativa Using Rotativa Best to follow the mentioned article for more information to generate PDF using Rotativa using MVC. Let's look at the code snippet for zipping.

using(ZipFile zipFile = new ZipFile()) {  
    //Get all filepath from folder  
    String[] files = Directory.GetFiles(Server.MapPath("/"));  
    string fileUniqueName = "Template"  
    foreach(string file in files) {  
        if (file.Contains(fileUniqueName.ToString())) {  
            zipFile.AddFile(file, @ "TemplateDocs_" + DateTime.Now);  
            //Adding files from filepath into Zip  
        }  
    }  
    Response.ClearContent();  
    Response.ClearHeaders();  
    //Set zip file name  
    Response.AppendHeader("content-disposition", "attachment; filename=TemplatedDocuments.zip");  
    zipFile.CompressionMethod = CompressionMethod.BZip2;  
    zipFile.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;  
    //Save the zip content in output stream  
    zipFile.Save(outputStream);  
}  
//Set the cursor to start position  
outputStream.Position = 0;  
String[] filesToDelete = Directory.GetFiles(Server.MapPath("/"));  
foreach(string file in filesToDelete) {  
    if (file.Contains(fileUniqueName.ToString())) {  
        FileInfo fi = new FileInfo(file);  
        fi.Delete();  
    }  
}  
return new FileStreamResult(outputStream, fileType);  


The above snippet is just required to start zipping and compressing the files. As you can see using block for the ZipFile is created with instantiation of its object.

Then, the files present under the path are navigated using Server.MapPath(""), Once the path is set, the files if with some unique string character in the filename needs to be searched and only zipped, is set to a variable.

Then each file is looped through and added to the ZipFile object, here zipFile.AddFiles(file, ZippedFolderName); ZipFolderName here is the name you set for the folder having all the files after extraction.

There are three compression levels for the ZipFile an enum which describes through code as below,
public enum CompressionMethod {  
    //  
    // Summary:  
    // No compression at all. For COM environments, the value is 0 (zero).  
    None = 0,  

        Deflate = 8,  
        
        BZip2 = 12  
}  


The above are the three algorithms used. I personally have used only BZip2 based on few good reviews.

Once compressed and all files inserted into the folder, the zipped folder is ready to be downloaded using the FileStreamResult in MVC action.

This is the simple explanation and the code snippet for the Zip file concept. This is simple and really handy to be used and it also provides the compression algorithms which are good to go with.

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: Pass Data To ASP.NET Web Service (ASMX) From Cross-Origin

clock July 30, 2018 11:15 by author Peter

In this blog, we are going to create a “Hello World” ASP.Net Web Service (ASMX) with parameters, and allow a request from cross-origin. Now, here we implement ASP.Net Web Service from Visual Studio 2017. We have created an empty ASP.Net Web Application solution and added “demo.asmx” in solution. Then, added code for “HelloWorld” method with “name” parameter as mention below snippet,
    [WebMethod] 
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
    public string HelloWorld(string text) { 
        return "Hello World " + text; 
    } 

We will invoke this web service using HTTP verb. So, we defined “ScriptMethodAttribute” for setting response format JSON.

We need to enable script service to invoke & pass parameters in Web Service from the script as shown in the below screenshot:

Then set demo.asmx as the startup page and run/test this web service on IIS:

Below is the example of “HelloWorld” webservice:
 

Now, we will create another ASP.NET web application which will have index.html to request “Hello world” web service using jQuery,
$.ajax({ 
    type: "POST", 
    url: "http://localhost:50555/Demo.asmx/HelloWorld", 
    data: { 
        'text': ' Peter' 
    }, 
    success: function(data) { 
        console.log(data); 
    }, 
    error: function(request, status, error) { 
        console.log(request); 
    } 
}); 


We will receive this error message: “No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:11111' is therefore not allowed access.”

To solve the above error we will need to add the following code under configuration node in web.config,
<system.webServer> 
    <httpProtocol> 
        <customHeaders> 
            <add name="Access-Control-Allow-Headers" value="accept, content-type" /> 
            <add name="Access-Control-Allow-Origin" value="http://localhost:11111" /> 
            <add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" /> 
        </customHeaders> 
    </httpProtocol> 
</system.webServer> 

Now, when we request this web service, it will successfully return and the response of the web service is as below in the console:

We have learned about passing data to ASP.NET Web Service (ASMX) from Cross-Origin.

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: Command Design Pattern In C# .NET

clock July 25, 2018 09:42 by author Peter

Command Design Pattern is a type of Behavioral Design Pattern.

Behavioral Design Pattern
It's about object communication, their responsibilities, and how they communicate to each other.

There might be a situation where we want to encapsulate the required information in an Object to perform some task and the task can be performed many times or whenever it's required. The command design pattern is the solution. It also gives you an easy way to implement Undo() that can just undo multiple commands.

  • Implementation - Typically, Implementation of Command Pattern is divided into 4 parts.
  • Command - That executes an action.
  • Receiver - Objects that receive the action from the command.

Invoker: Invoke the Commands to execute their actions. The Invoker may be a queue that holds commands for future execution, or holds such commands which can be used by different applications. The machine can be used to execute commands multiple times or can be used to undo the command.

Client
Client is the main program that asks for a command to be executed.
Consider the case of a banking application which is capable of making transactions i.e. Transfer, Deposit, Withdraw etc.
Let's identify each part of the command design pattern we discussed above.
Account of a customer ? Think, what it should be ?
Command ? Read command's definition again.......It says that it executes an action, but what action Account will it execute? Actions such as increment in account balance or decrements in account balance can be executed on Account by the Commands Deposit/Withdraw . So, if it receives actions, it means account is a Receiver.

So, Receiver is Account, and Command Deposit will add money from Account Balance and Withdraw command will subtract money from Account Balance.
/// <summary> 
/// Reciever of Command 
/// </summary> 
public class Account { 
    public string CustomerName { 
        get; 
        set; 
    } 
    public double AccountBalance { 
        get; 
        set; 
    } 
    public Account(string customerName, double accountBalance) { 
        CustomerName = customerName; 
        AccountBalance = accountBalance; 
    } 

/// <summary> 
/// Defines the action of Command those can be executed - will be called by Invoker 
/// IsCommandCompleted signals the command is completed and can be removed from Invoker 
/// </summary> 
public interface ITransaction { 
    void ExecuteCommand(); 
    bool IsCommandCompleted { 
        get; 
        set; 
    } 

/// <summary> 
/// Deposit Command 
/// </summary> 
public class Deposit: ITransaction { 
    private readonly Account _account; 
    private readonly double _amount; 
    public bool IsCommandCompleted { 
        get; 
        set; 
    } 
    public Deposit(Account account, double amount) { 
        _account = account; 
        _amount = amount; 
        IsCommandCompleted = false; 
    } 
    public void ExecuteCommand() { 
        _account.AccountBalance += _amount; 
        IsCommandCompleted = true; 
    } 

/// <summary> 
/// Withdraw Command 
/// </summary> 
public class Withdraw: ITransaction { 
    private readonly Account _account; 
    private readonly double _amount; 
    public bool IsCommandCompleted { 
        get; 
        set; 
    } 
    public Withdraw(Account account, double amount) { 
        _account = account; 
        _amount = amount; 
        IsCommandCompleted = false; 
    } 
    public void ExecuteCommand() { 
        if (_account.AccountBalance >= _amount) { 
            _account.AccountBalance -= _amount; 
            IsCommandCompleted = true; 
        } 
    } 

/// <summary> 
/// Transfer Command 
/// </summary> 
public class Transfer: ITransaction { 
        private readonly Account _fromAccount; 
        private readonly Account _toAccount; 
        private readonly double _amount; 
        public bool IsCommandCompleted { 
            get; 
            set; 
        } 
        public Transfer(Account fromAccount, Account toAccount, double amount) { 
            _fromAccount = fromAccount; 
            _toAccount = toAccount; 
            IsCommandCompleted = false; 
        } 
        public void ExecuteCommand() { 
            _fromAccount.AccountBalance -= _amount; 
            _toAccount.AccountBalance += _amount; 
            IsCommandCompleted = true; 
        } 


Lets write Invoker,
public class TransactionManager { 
    private readonly IList < ITransaction > _transactions = new List < ITransaction > (); 
    public bool HasInCompleteTransactions { 
        get { 
            return _transactions.Any(x => !x.IsCommandCompleted); 
        } 
    } 
    public IList < ITransaction > GetPendingTransactions() { 
        return _transactions ? .Where(x => !x.IsCommandCompleted) ? .ToList(); 
    } 
    public void AddTransaction(ITransaction transaction) { 
        _transactions.Add(transaction); 
    } 
    public void ProcessPendingTransactions() { 
        foreach(var transaction in _transactions.Where(x => !x.IsCommandCompleted)) { 
            transaction.ExecuteCommand(); 
        } 
    } 



The Client is responsible to create commands and pass them to the Invoker. The Commands will be held in the _transactions list, until the Client calls ProcessInCompleteTransactions. Then, the Invoker will try to execute each incomplete Command.

Invoker should not be aware of anything about what the Command can do, or what inputs it needs. All it needs to know is that the Command should be executed.

We will here simulate the client using our Console application to demonstrate.
class Program { 
    static void Main(string[] args) { 
        //Add 100 to the account - there should not be any pending job 
        TransactionManager manager = new CommandPattern.TransactionManager(); 
        Account accountAshish = new CommandPattern.Account("Ashish", 0); 
        ITransaction depositTransaction = new Deposit(accountAshish, 100); 
        manager.AddTransaction(depositTransaction); 
        manager.ProcessPendingTransactions(); 
        //try to withdraw 200 - transction will be pending since the balance is account is low 
        ITransaction withdrawTransaction = new Withdraw(accountAshish, 200); 
        manager.AddTransaction(withdrawTransaction); 
        manager.ProcessPendingTransactions(); 
        var pendingTransaction = manager.HasInCompleteTransactions; 
        Console.WriteLine(pendingTransaction); 
        Console.ReadKey(); 
        //add 200- still withdraw trasaction would be pending since we are adding money after withdraw failed attempt, 
        //we would need to execute failed transacction again 
        ITransaction anotherDepositTransaction = new Deposit(accountAshish, 200); 
        manager.AddTransaction(anotherDepositTransaction); 
        manager.ProcessPendingTransactions(); 
        Console.WriteLine(manager.HasInCompleteTransactions); 
        Console.ReadKey(); 
        if (manager.HasInCompleteTransactions) { 
            //reattempt failed transactions 
            ReattemptPendingTransactions(manager); 
        } 
        Console.WriteLine(manager.HasInCompleteTransactions); 
        Console.ReadKey(); 
        //Try Transfer 
        Account accountAvinash = new Account("Avinash", 10); 
        ITransaction transferTransaction = new Transfer(accountAshish, accountAvinash, 10); 
        manager.AddTransaction(transferTransaction); 
        manager.ProcessPendingTransactions(); 
        Console.WriteLine("Ashish account balance:" + accountAshish.AccountBalance); 
        Console.WriteLine("Anjali account balance:" + accountAvinash.AccountBalance); 
        Console.ReadKey(); 
    } 
    private static void ReattemptPendingTransactions(TransactionManager manager) { 
        var pendingTransactions = manager.GetPendingTransactions(); 
        foreach(var item in pendingTransactions) { 
            item.ExecuteCommand(); 
        } 
    } 


Enhancement Undo
Suppose you want to undo the command. Modify your code, add Undo in your command.

You should facilitate your program with the undo all command and undo a particular command. In case of a particular command undo, you would need some kind of identifier which can uniquely identify the command (i.e. Id) and perform undo on it. We should be able to Undo successful commands also, we can have some status of command which tells us if command is executed successfully or not, unprocessed, Undo Successful, Undo Failed etc.

Transaction would look like,
public interface ITransaction { 
    int Id { 
        get; 
        set; 
    } 
    void ExecuteCommand(); 
    bool IsCommandCompleted { 
        get; 
        set; 
    } 
    void Undo(); 


Implement modified interface in all the Commands Deposit, Withdraw and Transfer

Create an enum to set Command state
/// <summary> 
/// Command sate enum 
/// </summary> 
public enum CommandState { 
    UnProcessed, 
    ExecutionFailed, 
    ExecutionSuccessed, 
    UndoDone, 
    UndoFailed 

public interface ITransaction { 
    int Id { 
        get; 
        set; 
    } 
    void ExecuteCommand(); 
    bool IsCommandCompleted { 
        get; 
        set; 
    } 
    CommandState Status { 
        get; 
        set; 
    } 
    void Undo(); 
} === === === === === == Other Updated Classes === === === === === === === === === === === == private static void ReattemptPendingTransactions(TransactionManager manager) { 
    var pendingTransactions = manager.GetPendingTransactions(); 
    foreach(var item in pendingTransactions) { 
        item.ExecuteCommand(); 
    } 


/// <summary> 
/// Reciever of Command 
/// </summary> 
public class Account { 
    public string CustomerName { 
        get; 
        set; 
    } 
    public double AccountBalance { 
        get; 
        set; 
    } 
    public Account(string customerName, double accountBalance) { 
        CustomerName = customerName; 
        AccountBalance = accountBalance; 
    } 

/// <summary> 
/// Defines the action of Command those can be executed - will be called by Invoker 
/// IsCommandCompleted signals the command is completed and can be removed from Invoker 
/// </summary> 
public interface ITransaction { 
    int Id { 
        get; 
        set; 
    } 
    void ExecuteCommand(); 
    bool IsCommandCompleted { 
        get; 
        set; 
    } 
    CommandState Status { 
        get; 
        set; 
    } 
    void Undo(); 

/// <summary> 
/// Command sate enum 
/// </summary> 
public enum CommandState { 
    UnProcessed, 
    ExecutionFailed, 
    ExecutionSuccessed, 
    UndoDone, 
    UndoFailed 

/// <summary> 
/// Deposit Command 
/// </summary> 
public class Deposit: ITransaction { 
    private readonly Account _account; 
    private readonly double _amount; 
    public bool IsCommandCompleted { 
        get; 
        set; 
    } 
    public int Id { 
        get; 
        set; 
    } 
    public CommandState Status { 
        get { 
            throw new NotImplementedException(); 
        } 
        set { 
            throw new NotImplementedException(); 
        } 
    } 
    public Deposit(int Id, Account account, double amount) { 
        this.Id = Id; 
        _account = account; 
        _amount = amount; 
        IsCommandCompleted = false; 
        Status = CommandState.UnProcessed; 
    } 
    public void ExecuteCommand() { 
        _account.AccountBalance += _amount; 
        IsCommandCompleted = true; 
        Status = CommandState.ExecutionSuccessed; 
    } 
    public void Undo() { 
        if (_account.AccountBalance >= _amount) { 
            _account.AccountBalance -= _amount; 
            Status = CommandState.UndoDone; 
        } else { 
            Status = CommandState.UndoFailed; 
        } 
    } 

/// <summary> 
/// Withdraw Command 
/// </summary> 
public class Withdraw: ITransaction { 
    private readonly Account _account; 
    private readonly double _amount; 
    public bool IsCommandCompleted { 
        get; 
        set; 
    } 
    public int Id { 
        get; 
        set; 
    } 
    public CommandState Status { 
        get; 
        set; 
    } 
    public Withdraw(int Id, Account account, double amount) { 
        _account = account; 
        _amount = amount; 
        IsCommandCompleted = false; 
        this.Id = Id; 
        Status = CommandState.UnProcessed; 
    } 
    public void ExecuteCommand() { 
        if (_account.AccountBalance >= _amount) { 
            _account.AccountBalance -= _amount; 
            IsCommandCompleted = true; 
            Status = CommandState.ExecutionSuccessed; 
        } else { 
            Status = CommandState.ExecutionFailed; 
        } 
    } 
    public void Undo() { 
        _account.AccountBalance += _amount; 
        Status = CommandState.UndoDone; 
    } 

/// <summary> 
/// Transfer Command 
/// </summary> 
public class Transfer: ITransaction { 
    private readonly Account _fromAccount; 
    private readonly Account _toAccount; 
    private readonly double _amount; 
    public bool IsCommandCompleted { 
        get; 
        set; 
    } 
    public int Id { 
        get; 
        set; 
    } 
    public CommandState Status { 
        get; 
        set; 
    } 
    public Transfer(int Id, Account fromAccount, Account toAccount, double amount) { 
        _fromAccount = fromAccount; 
        _toAccount = toAccount; 
        IsCommandCompleted = false; 
        _amount = amount; 
        this.Id = Id; 
        Status = CommandState.UnProcessed; 
    } 
    public void ExecuteCommand() { 
        if (_fromAccount.AccountBalance >= +_amount) { 
            _fromAccount.AccountBalance -= _amount; 
            _toAccount.AccountBalance += _amount; 
            IsCommandCompleted = true; 
            Status = CommandState.ExecutionSuccessed; 
        } else { 
            Status = CommandState.ExecutionFailed; 
        } 
    } 
    public void Undo() { 
        if (_toAccount.AccountBalance >= _amount) { 
            _toAccount.AccountBalance -= _amount; 
            _fromAccount.AccountBalance += _amount; 
            Status = CommandState.UndoDone; 
        } else { 
            Status = CommandState.UndoFailed; 
        } 
    } 

public class TransactionManager { 
    private readonly IList < ITransaction > _transactions = new List < ITransaction > (); 
    public bool HasInCompleteTransactions { 
        get { 
            return _transactions.Any(x => !x.IsCommandCompleted); 
        } 
    } 
    public IList < ITransaction > GetPendingTransactions() { 
        return _transactions ? .Where(x => !x.IsCommandCompleted) ? .ToList(); 
    } 
    public void AddTransaction(ITransaction transaction) { 
        _transactions.Add(transaction); 
    } 
    public void ProcessPendingTransactions() { 
        foreach(var transaction in _transactions.Where(x => !x.IsCommandCompleted)) { 
            transaction.ExecuteCommand(); 
        } 
    } 


Note
I won't create a client for these extended functionalities, I want you to try this. If you find any difficulty, please reach out to me through the Contact Us Page.

Command Design Pattern is often used with message queue applications such as, logging. In case of sudden system shut down/ crash, our system would be able read the incomplete commands from the queue, and resume without any data loss. Another scenario is if you want to interact with some service and that service is not available, this pattern will help you in reattempting the operation once service is up again.

Since it adds the complexity to the system, it is recommended to use this pattern in the big system where reliability is important.

HostForLIFE.eu ASP.NET Core 2.2.1 Hosting
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.

 



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in