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

European ASP.NET Core Hosting :: Consuming RabbitMQ Messages In ASP.NET Core

clock March 26, 2019 11:42 by author Peter

Background tasks play a very important role when we are building a distributed system. The most common scenario is consuming the service bus's message. In this article, I'd like to present how to consume the RabbitMQ message via BackgroundService in ASP.NET Core.
Run RabbitMQ Host

We should set up an instance of RabbitMQ. The fastest way is to use Docker.
docker run -p 5672:5672 -p 15672:15672 rabbitmq:management  

After running the Docker container, we are able to view the management page via http://localhost:15672.

Consuming RabbitMQ Messages In ASP.NET Core
Setup the BackgroundService
Here, we create a new class named ConsumeRabbitMQHostedService that is inherited from BackgroundService.
BackgroundService is a base class for implementing a long-running IHostedService. It provides the main work needed to set up the background task.
Here is an example to demonstrate how to consume RabbitMQ messages.
public class ConsumeRabbitMQHostedService : BackgroundService 

    private readonly ILogger _logger; 
    private IConnection _connection; 
    private IModel _channel; 
 
    public ConsumeRabbitMQHostedService(ILoggerFactory loggerFactory) 
    { 
        this._logger = loggerFactory.CreateLogger<ConsumeRabbitMQHostedService>(); 
        InitRabbitMQ(); 
    } 
 
    private void InitRabbitMQ() 
    { 
        var factory = new ConnectionFactory { HostName = "localhost" }; 
 
        // create connection 
        _connection = factory.CreateConnection(); 
 
        // create channel 
        _channel = _connection.CreateModel(); 
 
        _channel.ExchangeDeclare("demo.exchange", ExchangeType.Topic); 
        _channel.QueueDeclare("demo.queue.log", false, false, false, null); 
        _channel.QueueBind("demo.queue.log", "demo.exchange", "demo.queue.*", null); 
        _channel.BasicQos(0, 1, false); 
 
        _connection.ConnectionShutdown += RabbitMQ_ConnectionShutdown; 
    } 
 
    protected override Task ExecuteAsync(CancellationToken stoppingToken) 
    { 
        stoppingToken.ThrowIfCancellationRequested(); 
 
        var consumer = new EventingBasicConsumer(_channel); 
        consumer.Received += (ch, ea) => 
        { 
            // received message 
            var content = System.Text.Encoding.UTF8.GetString(ea.Body); 
 
            // handle the received message 
            HandleMessage(content); 
            _channel.BasicAck(ea.DeliveryTag, false); 
        }; 
 
        consumer.Shutdown += OnConsumerShutdown; 
        consumer.Registered += OnConsumerRegistered; 
        consumer.Unregistered += OnConsumerUnregistered; 
        consumer.ConsumerCancelled += OnConsumerConsumerCancelled; 
 
        _channel.BasicConsume("demo.queue.log", false, consumer); 
        return Task.CompletedTask; 
    } 
 
    private void HandleMessage(string content) 
    { 
        // we just print this message  
        _logger.LogInformation($"consumer received {content}"); 
    } 
     
    private void OnConsumerConsumerCancelled(object sender, ConsumerEventArgs e)  {  } 
    private void OnConsumerUnregistered(object sender, ConsumerEventArgs e) {  } 
    private void OnConsumerRegistered(object sender, ConsumerEventArgs e) {  } 
    private void OnConsumerShutdown(object sender, ShutdownEventArgs e) {  } 
    private void RabbitMQ_ConnectionShutdown(object sender, ShutdownEventArgs e)  {  } 
 
    public override void Dispose() 
    { 
        _channel.Close(); 
        _connection.Close(); 
        base.Dispose(); 
    } 


Configure Services
We should configure this hosted service with the background task logic in ConfigureServices method.
public void ConfigureServices(IServiceCollection services) 

    // others ... 
     
    services.AddHostedService<ConsumeRabbitMQHostedService>(); 
}  

Result

After running this app, we may get the following output in the terminal.Turning to the Management UI of RabbitMQ, we find that it creates a new exchange and a new queue.

The next time we try to publish a message to show the background task is running well, we get the following result.




ASP.NET Core 2.2.3 Hosting - HostForLIFE.eu :: Show Alert Message Box using JavaScript jQuery in ASP.NET

clock March 20, 2019 12:03 by author Peter

Today, I will explain you about Showing Alert Message Box from client Side on ASP.NET Core 2.2.3 using JavaScript and JQuery. In the Following, this is jQuery Code Snippet to show/display alert message:

//Function for jQuery
$(function () {
$('#btnUsingjQuery').click(function () {
alert('Alert using jQuery Function!');
});
});

And, this is the JavaScript code to show or display alert message:
//Function for JavaScript
function alertUsingJavaScript() {
alert('Alert using JavaScript Function!');
}

Show Alert Message – (.aspx)
Here is the code snippet for your .aspx webpage:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>How to show alert message using jQuery/JavaScript in ASP.NET
</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js">
</script>
<script type="text/javascript">
//Function for JavaScript
function alertUsingJavaScript() {
alert('Alert using JavaScript Function!');
}
//Function for jQuery
$(function () {
$('#btnUsingjQuery').click(function () {
alert('Alert using jQuery Function!');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<h4>
Show alert message using JavaScript/jQuery in Asp.net</h4>
<div>
<input id="btnUsingJavaScript" type="button" onclick="alertUsingJavaScript()"
value="Using JavaScript" />
<input id="btnUsingjQuery" type="button" value="Using jQuery" />
</div>
</form>
</body>
</html>

You can see i’d added onclick=”alertUsingJavaScript()” when calling function using JavaScript. Just in case of jQuery, we are able to bind click event directly on window load as $(‘#btnUsingjQuery’).click(function () ); });. And here is the result
:



European ASP.NET Hosting - HostForLIFE.eu :: jQuery PJAX Implementation In ASP.NET Core

clock February 26, 2019 11:15 by author Peter

PJAX is a jQuery plugin that uses AJAX and pushState to deliver a fast browsing experience with real permalinks, page titles, and a working back button. It is available to download from GitHub.

In all websites, the header and footer remain the same for all pages. Only the page contents (the content in the middle area between the header and footer) are changed for each page. PJAX uses this concept to fetch only the page contents while the header and footer remains the same for each page. In short, you can also say PJAX is the brother of the Update Panel of Web Forms that works for ASP.NET Core.

With PJAX, you get the following advantages.

    The website becomes fast since the header and footer are not loaded for different pages.
    You website behaves like a SPA (Single Page Application), and you don’t need to employ Angular framework in your ASP.NET Core Application.
    If you have worked with Update Panel of ASP.NET Web Forms then it is quite similar to it.

This is how PJAX will work.
See the below video which illustrates the working of PJAX.

PJAX Implementation in ASP.NET Core

Integration of PJAX in ASP.NET Core involves the following things.

Layout.cshtml View
In your application _Layout.cshml View, add jQuery and PJAX script links. You do this inside the head section:
    <script src="https://code.jquery.com/jquery-2.2.4.js"></script> 
    <script src="~/js/jquery.pjax.js"></script> 
    Also call PJAX on all anchors inside the #main element.  
    <script type="text/javascript"> 
        $(function () { 
            // call pjax 
            $(document).pjax('#menu li a', '#main', { timeout: 10000 }); 
     
        }); 
    </script> 


Loading Image
If you want to show the loading image when a new page contents are being fetched then add the following code inside the script section of Layout:
    $(document).ajaxStart(function () { 
        $("#loadingDiv").show(); 
    }); 
     
    $(document).ajaxComplete(function (event, jqxhr, settings) { 
        $("#loadingDiv").hide(); 
    }); 


Also, place the loading image somewhere in your layout.
    <div id="loadingDiv" style="display:none;"> 
        <img src="~/loading.gif" /> 
    </div> 


Do not worry as the source code contains all the loading image codes. Do check it.

Add some links to your _Layout.cshtml View. On these links, PJAX will work so when these links are clicked then their page’s contents are loaded by PJAX (but the header and footer area are not loaded).
    <ul> 
        <li><a href="/Home/Index">Index</a></li> 
        <li><a href="/Home/About">About</a></li> 
        <li><a href="/Home/Contact">Contact</a></li> 
    </ul> 


Don’t forget to add the #main element on the Layout so that PJAX only fetches the contents inside this #main element with AJAX.
    <div id="main"> 
        @RenderBody()  
    </div> 

Controller
Add a controller called Home with the following 3 action methods:

    public IActionResult Index() 
    { 
        if (string.IsNullOrEmpty(Request.Headers["X-PJAX"])) 
            return View(); 
        else 
            return PartialView("/Views/Home/Index.cshtml"); 
    } 
     
    public IActionResult About() 
    { 
        if (string.IsNullOrEmpty(Request.Headers["X-PJAX"])) 
            return View(); 
        else 
            return PartialView("/Views/Home/About.cshtml"); 
    } 
     
    public IActionResult Contact() 
    { 
        if (string.IsNullOrEmpty(Request.Headers["X-PJAX"])) 
            return View(); 
        else 
            return PartialView("/Views/Home/Contact.cshtml"); 
    }  


Make sure that the Action methods that are called by PJAX (i.e. clicking on menu links in my case) return PartialViews. Since PJAX sends ‘X-PJAX’ request in the HTTP Header therefore I can easily make a selection of View or Partial View by checking the HTTP header.

The condition applied in each action method that does this work is:
    if (string.IsNullOrEmpty(Request.Headers["X-PJAX"])) 
        return View(); 
    else 
        return PartialView("/Views/Home/Index.cshtml");  


Views

Add the 3 Views called ‘Index.cshtml’, ‘About.cshtml’ and ‘Contact.cshtml’ inside the ‘Views/Home’ folder:

Index.cshtml
    <div class="templatemo_content_area"> 
        <h1>WELCOME TO Index Page</h1> 
    </div> 


About.cshtml
    <div class="templatemo_content_area"> 
        <h1>WELCOME TO About Page</h1> 
    </div> 


Contact.cshtml
    <div class="templatemo_content_area"> 
        <h1>WELCOME TO Contact Page</h1> 
    </div> 


Also add _ViewStart.cshtml View inside the ‘Views’ folder:
    @{ 
        Layout = "_Layout"; 
    }



ASP.NET Core 2.2.1 Hosting - HostForLIFE.eu :: Cookies in ASP.Net

clock February 8, 2019 08:27 by author Peter

Today I am here to explain cookies in ASP.Net. You have seen “Remember Me” in every login portal or website. I will tell you how it works in this demo.

Cookies
It is a small text file stored in a client local machine or in the memory of a client browser session. It is used to state management. We can store a small piece of information in this file. It stores information in a plain text file.

How It Works

When the client sends a request to the server then the server sends response cookies with a session Id. If the cookies are saved the first time then the cookies are used for subsequent requests.

I am giving you a small demonstration. In this demonstration I will show you how to use use cookies and what “Remember Me” is.

When the user logs in with “Remember Me” selected then cookies play an important role. If Remember Me is selected then cookies will be created with the userid and an encrypted word. Cookies are easily readable for every user in the local machine. That’s why I use md5 to encryt my word for cookies.

Check cookies on Page_Load:
    HttpCookie _objCookie = Request.Cookies["Test"]; 
     
            if (_objCookie != null) 
            { 
                bool bCheck = IsValidAuthCookie(_objCookie, "encrypt"); 
                if (bCheck) 
                { 
                    Response.Redirect("WelcomePage.aspx?User=" + Convert.ToString(_objCookie.Value.ToString().Split('|')[0]) + ""); 
                } 
            } 


I check cookies on the login page load every time. If cookies exist then I redirect the welcome.aspx directly.
LoginButton_Click
    bool IsLogin = IsValidLogin(txtUserId.Text.Trim(), txtword.Text.Trim());   
    if (IsLogin)   
    {   
        if (chkRememberMe.Checked)   
        {   
            CreateAuthCookie(txtUserId.Text.Trim(), txtword.Text.Trim(), "encrypt");   
         }   
         Response.Redirect("WelcomePage.aspx?User=" + txtUserId.Text.Trim() + "");   
    }


If “Remember me” is checked then I create cookies with User Id and encrypted word.
Suppose you login with “Remember me” checked and close the application without LogOut. Now when you open again your login page it will redirect you to the welcome.aspx page automatically. And if you logout the application then your cookies will be removed. You will see this scenario on Gmail.com, Facebook.com and so on.

Create Hash word with Md5 encryption as in the following:
    public string CreateHash(string word, string salt) 
    { 
        // Get a byte array containing the combined word + salt. 
        string authDetails = word + salt; 
        byte[] authBytes = System.Text.Encoding.ASCII.GetBytes(authDetails); 
     
        // Use MD5 to compute the hash of the byte array, and return the hash as 
        // a Base64-encoded string. 
        var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); 
        byte[] hashedBytes = md5.ComputeHash(authBytes); 
        string hash = Convert.ToBase64String(hashedBytes); 
     
        return hash; 
    }
 

Advantages
Cookies do not require any server resources since they are stored on the client.
Cookies are easy to implement.

Disadvantages
Cookies can be disabled on user browsers
Cookies are transmitted for each HTTP request/response causing overhead on bandwidth
No security for sensitive data.

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 :: What Is SSL Or TLS?

clock January 15, 2019 10:10 by author Peter

Many people are using these terms interchangeably. But the correct term is TLS. Well, let us understand what this TLS is and why we really need it.
 
Most of us are already aware that HTTP is a plain text protocol which doesn’t have its own transport security mechanisms. In other words, HTTP is a protocol which sends the data to a server and gets a response without any built-in feature or mechanism to protect the data packet against tampering.
 
To protect our packet which is traveling through HTTP, some sort of secure tunneling is required and that secure tunneling is provided by a protocol called TLS, a.k.a., SSL. Here, HTTP and TLS come together.
 
Usually, people associate SSL/TLS with encryption, but that is not the only feature SSL provides. There are a few more features, such as -
  • Server Authentication – It makes sure that the communication with the right server is made.
  • Veracity Protection – It promotes integrity and makes sure that no one in between is reading our data.
  • Confidentiality – It makes sure that no one should know what data is being transmitted.
Associating the above features with HTTP makes HTTPS more reliable and authentic. Now, the question arises --  how to achieve this or how to implement this SSL. Wait for my next blog to learn more about SSL certificates.

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 Hosting - HostForLIFE.eu :: How .NET Support Multiple Languages?

clock December 13, 2018 10:27 by author Peter

An application is said to be multilingual if it can be deployed in many different languages. With .NET, all of the languages including Visual Basic, .NET, C#, and J# compile to a common Intermediate language (IL). This makes all languages interoperable. Microsoft has created Java bytecode, which is a low-level language with a simple syntax, which can be very quickly translated into native machine code.

CLR
.NET Framework is a multilingual application because of CLR. CLR is the key of .NET Framework. The code running under the control of the CLR is often termed as managed code.

The main task of CLR is to convert compiled code into the native code.
.NET Framework has one or more compilers; for e.g., VB .NET, C#, C++, JScript or any third party compiler such as COBOL. Anyone of these compilers will convert your source code into Microsoft Intermediate Language (MSIL). The main reason for .NET to be multilingual is that you can compile your code from IL and this compiled code will be interoperable with the code that has been compiled to IL from another language.

It simply means that you can create pages in different languages (like C#, VB .NET, J# etc.) and once all of these pages are compiled they all can be used in a single application. Let us understand this point clearly with an example.

Let us consider a situation where a customer needs an application to be ready in 20 days. For completing the application in 20 days we want 30 developers who all know the specific language but we have 15 developers who know C# and 15 developers who know VB .NET. In this situation, if we don’t use .NET then we need to hire 15 more developers of C# or VB .NET which is a difficult and costly solution. Now, if we use .NET then we can use C# and VB .NET language in the same application. This is possible because once C# code is compiled from IL it becomes interoperable with VB .NET code which is compiled from IL.

Then JIT (Just In Time) of CLR converts this MSIL code into native code using metadata which is then executed by OS.

CLR stands for common language runtime. Common language runtime provides other services like memory management, thread management, remoting, and other security such as CTS and CLS.

CLR is a layer between an operating system and .NET language, which uses CTS and CLS to create code.

CTS
CTS stands for the common type system. CTS defines rules that common language runtime follows when we are declaring, using and managing type. CTS deals with the data type. .NET supports many languages and every language has its own data type. One language cannot understand data types of another language.

For example: When we are creating an application in C#, we have int and when we are creating an application in VB .NET, we have an integer. Here CTS comes into play --  after the compilation, CTS converts int and integer into the int32 structure.

CLS
CLS stands for common language specification.
CLS is a subset of CTS and it declares all the rules and restrictions that all languages under .NET Framework must follow. The language which follows these rules is known as CLS compliant.
For example, we can use multiple inheritances in c++ but when we use the same code in C# it creates a problem because C# does not support multiple inheritances. Therefore, CLS restricts multiple inheritances for all language.

One other rule is that you cannot have a member with the same name and a different case. In C# add() and Add() are different because it is case sensitive but a problem arises when we use this code in VB .NET because it is not case-sensitive and it considers add() and Add() as the same.

HostForLIFE.eu ASP.NET Core 2.2 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 :: The Common Language Runtime Of Microsoft’s .Net Framework

clock December 5, 2018 10:02 by author Peter

The CLR is a runtime environment of .NET to execute applications. The major function of the CLR is converting the Managed Code to native code and executing the program. Furthermore, it acts as a layer between operating systems and apps that are written in .NET languages. The common language runtime handles execution of code as well as provides useful services for implementing the program. Aside from code execution, the CLR also provides services like memory management, security management, thread management, compilation, code verification, and other system services.

CLR is due for a makeover
The common language runtime of Microsoft is due for a makeover with Microsoft announcing plans to make it more scalable and efficient. The key to the modernization would be enhancements on the intermediate language underlying the CRL, called IL, that has not been upgraded in a decade. Microsoft wants to boost the IL as well as make the CLR a richer target for programming languages. The aim of the common language runtime is to run .NET programs in an efficient manner.

One imminent enhancement includes Span<T>, pronounced ‘span of tee’. It’s a new kind that would offer framework and language features to achieve more performing, safer, low-level code. The T in Span<T> means type parameter. It would be used by C# as well as other languages to build more efficient code, which does not require copying big amounts of data or pause for garbage collection. New CRL versions would have ‘inside knowledge’ regarding Span<T> to boost speed. It will be rolled out in the next few releases of .NET.

Serving as the counterpart of Microsoft to the JVM of the world of Java, the common language runtime provides management of code of .NET languages, which include Visual Basic, C# and F#. The source code is compiled by the language compilers to the IL code. The CLR tunes the program through the execution of the IL and translating output into a machine code while the program runs. Other services are provided by the common language runtime include automatic management of memory and type safety, saving .NET programmers from providing the services.

THE ROLE OF THE COMMON LANGUAGE RUNTIME IN THE DOT NET FRAMEWORK
  1. Base Class libraries
    Provides class libraries support to an app when required.
  2. Thread support
    Threads are managed under the CLR. Threading means the parallel execution of code. Basically, threads are lightweight processes that are responsible for multi-tasking in a single app.
  3. MSIL code to native code
    The CLR is an engine that compiles the source code to an intermediate language. The intermediate language’s called the Microsoft Intermediate Language. During program execution, the MSIL’s converted to the native code of the machine code. The conversion is possible via the Just-In-Time compiler. At compilation, the end result is the PE or the Portable Executable file.
  4. Code Manager
    The common language runtime manages code. When compiling a .NET app, one does not generate code that could actually execute on the machine. The MSIL or the Microsoft Intermediate Language or IL could actually be generated. All code of .NET is IL code. The IL code is also called the Managed Code since the CLR of.NET manages it.
  5. COM Marshaler
    It enables communication between the app and COM objects.
  6. CLS or Common Language Specification
    It is used to communicate objects that are written in various .NET languages. It defines the standards and rules to which languages should adhere to in order to be compatible with the other languages of .NET. This lets C# developers to inherit from classes, which are defined in VB.NET or other compatible languages of .NET.
  7. Debug Engine
    The CLR enables performing debugging an app during runtime.
  8. Type Checker
    It verifies the types used in the app with CLS or CTS standards that are supported by the common language runtime and provides type safety.
  9. CTS or the Common Type System
    It specifies types of data that are created in a couple of different languages compiled into the base common data type system.
  10. Security Engine
    This enforces security permission at code level security, machine level security and folder level security with the use of .NET framework setting and tools provided by .NET.
  11. Exception Manager
    It handles exceptions thrown by an app while executing Try-catch block that is provided by an exception. In ‘Try’ block used where a code part expects an error. In ‘Catch’ block throws exception caught from the ‘try’ block. If there’s no catch block, it would terminate an app.
  12. Garbage Collector
    The Garbage Collectors handles automatic memory management. Furthermore, it releases memory of unused objects in an app that provides automatic memory management.
Hire ASP.NET developers from India for maximum results and solutions. With the improvements set to boost the .NET’s CLR, applications, and solutions are more effective and streamlined.

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 :: Assembly Attributes

clock November 27, 2018 10:01 by author Peter

I have listed down some of the assembly attributes.

    [assembly: AssemblyKeyFile(@"key.snk")] 
    [assembly: InternalsVisibleTo("System.Numerics, PublicKey=00000000000000000400000000000000", AllInternalsVisible=false)] 
    [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] 
    [assembly: AssemblyDelaySign(true)] 
    [assembly: InternalsVisibleTo("System, PublicKey=00000000000000000400000000000000", AllInternalsVisible=false)] 
    [assembly: InternalsVisibleTo("System.Core, PublicKey=00000000000000000400000000000000", AllInternalsVisible=false)] 
    [assembly: AllowPartiallyTrustedCallers] 
    [assembly: NeutralResourcesLanguage("en-US")] 
    [assembly: RuntimeCompatibility(WrapNonExceptionThrows=true)] 
    [assembly: Guid("BED7F4EA-1A96-11d2-8F08-00A0C9A6186D")] 
    [assembly: ComCompatibleVersion(1, 0, 0xce4, 0)] 
    [assembly: TypeLibVersion(2, 4)] 
    [assembly: DefaultDependency(LoadHint.Always)] 
    [assembly: StringFreezing] 
    [assembly: ComVisible(false)] 
    [assembly: CLSCompliant(true)] 
    [assembly: CompilationRelaxations(8)] 
    [assembly: SecurityRules(SecurityRuleSet.Level2, SkipVerificationInFullTrust=true)] 
    [assembly: AssemblyTitle("sample.dll")] 
    [assembly: AssemblyDescription("sample.dll")] 
    [assembly: AssemblyDefaultAlias("sample.dll")] 
    [assembly: AssemblyCompany("Microsoft Corporation")] 
    [assembly: AssemblyProduct("Microsoft\x00ae .NET Framework")] 
    [assembly: AssemblyCopyright("\x00a9 Microsoft Corporation.  All rights reserved.")] 
    [assembly: AssemblyFileVersion("4.0.30319.225")] 
    [assembly: AssemblyInformationalVersion("4.0.30319.225")] 
    [assembly: SatelliteContractVersion("4.0.0.0")] 
    [assembly: AssemblyTargetedPatchBand("1.0.21-102")] 
    [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification=true)] 

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 :: Firebase Cloud Messaging From .Net

clock November 22, 2018 10:05 by author Peter

In developing mobile web backends you might need users to broadcast messages such as push notifications to single or all  mobile subscribers from the cloud using services like Firebase Cloud Messaging (FCM).
 
In this article we will focus on sending push notifications from a .Net application using Firebase.Notification library. This library makes it very easy to send push notifications from Firebase using C#
 
To begin, download the library from Nuget:
    Install-Package Firebase.Notification -Version 1.0.0 

Using the library:
    using (var firebase = new Firebase()) 
    { 
        firebase.ServerKey = "{Your Server Key}"; 
        var id = "{Your Device Id}"; 
        firebase.PushNotifyAsync(id,"Hello","World").Wait(); 
        Console.ReadLine(); 
    }        


Error Handling and Debugging
Trace errors in your output window, all errors from this library will be captured under the category Firebase.Notification for easy debugging,

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 .NET Is A Multilingual Framework?

clock November 13, 2018 08:18 by author Peter

An application is said to be multilingual if it can be deployed in many different languages. With .NET, all of the languages including Visual Basic, .NET, C#, and J# compile to a common Intermediate language (IL). This makes all languages interoperable. Microsoft has created Java bytecode, which is a low-level language with a simple syntax, which can be very quickly translated into native machine code.

CLR
.NET Framework is a multilingual application because of CLR.CLR is the key of .NET Framework. The code running under the control of the CLR is often termed as managed code.The main task of CLR is to convert compiled code into the native code. .NET Framework has one or more compilers; for e.g., VB .NET, C#, C++, JScript or any third party compiler such as COBOL.

Anyone of these compilers will convert your source code into Microsoft Intermediate Language (MSIL). The main reason for .NET to be multilingual is that you can compile your code from IL and this compiled code will be interoperable with the code that has been compiled to IL from another language.

It simply means that you can create pages in different languages (like C#, VB .NET, J# etc.) and once all of these pages are compiled they all can be used in a single application. Let us understand this point clearly with an example.

Let us consider a situation where a customer needs an application to be ready in 20 days. For completing the application in 20 days we want 30 developers who all know the specific language but we have 15 developers who know C# and 15 developers who know VB .NET. In this situation, if we don’t use .NET then we need to hire 15 more developers of C# or VB .NET which is a difficult and costly solution. Now, if we use .NET then we can use C# and VB .NET language in the same application. This is possible because once C# code is compiled from IL it becomes interoperable with VB .NET code which is compiled from IL.


Then JIT (Just In Time) of CLR converts this MSIL code into native code using metadata which is then executed by OS.

CLR stands for common language runtime. Common language runtime provides other services like memory management, thread management, remoting, and other security such as CTS and CLS. CLR is a layer between an operating system and .NET language, which uses CTS and CLS to create code.

CTS
CTS stands for the common type system. CTS defines rules that common language runtime follows when we are declaring, using and managing type. CTS deals with the data type. .NET supports many languages and every language has its own data type. One language cannot understand data types of another language. For example: When we are creating an application in C#, we have int and when we are creating an application in VB .NET, we have an integer. Here CTS comes into play --  after the compilation, CTS converts int and integer into the int32 structure.

CLS
CLS stands for common language specification. CLS is a subset of CTS and it declares all the rules and restrictions that all languages under .NET Framework must follow. The language which follows these rules is known as CLS compliant. For example, we can use multiple inheritances in c++ but when we use the same code in C# it creates a problem because C# does not support multiple inheritances. Therefore, CLS restricts multiple inheritances for all language. One other rule is that you cannot have a member with the same name and a different case.

In C# add() and Add() are different because it is case sensitive but a problem arises when we use this code in VB .NET because it is not case-sensitive and it considers add() and Add() as the same.

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

HostForLIFE 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 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Month List

Tag cloud

Sign in