Full Trust European Hosting

BLOG about Full Trust Hosting and Its Technology - Dedicated to European Windows Hosting Customer

Magento Hosting - HostForLIFE.eu :: How To Install Magento Security Patch?

clock July 1, 2020 13:18 by author Peter

Making money is serious business, and it does take time for every effort to nurture and mature. Online shopping is actually only a small part of the wilderness of e-commerce. Web shopping which includes online transactions stock, download the software directly from the web actually connecting businesses to consumers is only about 20% of the total e-commerce. In fact, more in the form of trade relations business to business that facilitates the process of purchasing between companies. Many people hope that the possible occurrence of micro-transactions that allow people to pay in the form of coins some thousand or hundred dollars to access content or games on the Internet. One CMS that is used to create an online shop is Magento.

Magento is a premium shopping platform that Provides a platform online store with reviews Reviews their hosting packages. Features on Magento especially reporting features. This online store also handles complex system of discounts and voucher systems that can be integrated with other systems. Magento is an online shop for professionals who need a shopping system with detailed reporting. Magento has two versions items, Community (Open Source) and Professional.

Magento released a new patch for the Community Edition 1.9 and Enterprise Edition 1.14 to address security issues, including remote code execution and information leak vulnerabilities.

Be sure to test the patch in a development environment first, as it can affect extensions and customizations :

You can download the patch for both Community Edition and Enterprise Edition from the following options:

  • Partners: Go to the Partner Portal, select Technical Resources and then select Download from the Enterprise Edition panel. Next, navigate to Magento Enterprise Edition > Patches & Support and look for the folder titled “Security Patches – July-October.”
  • Enterprise Edition Merchants: Go to My Account, select the Downloads tab, and then navigate to Magento Enterprise Edition > Support Patches. Look for the folder titled “Security Patches – October 2015” .Merchants can also upgrade to the latest version of the Enterprise Edition and receive the security fixes as part of the core code.
  • Community Edition Merchants: Patches for earlier versions of Community Edition can be found on the Community Edition download page (look for SUPEE-67.88) Merchants can also upgrade today to the latest version of the Community Edition and receive the security fixes as part of the core code.

Before installing the patch check whether old patches are installed correctly. Some patches depend on other patches to be installed already.

Simply unpack the archive and replace files on your store by uploading app/ and lib/ folders into your Magento root directory.
If you use PHP opcode caches (APC/XCache/eAccelerator) make sure to flush it after patching, otherwise code will continue to run from caches.

If you have SSH access, it would be simpler to install the patch. Before installing the patch make sure to disable Magento Compiler at System > Configuration > Tools > Magento Compiler and clear compiled cache (if compiler is used).

If you have no SSH access, then to apply to the patch, you can simply upgrade your installation to the latest Magento version.

After the patch is installed successfully, check whether all CMS , home page, category pages and landing pages are running correctly without any issues. Magento security patch Supee 6788 affects the page layout, transaction emails and order confirmation notifications.

The Magento security patch supee 6788 has introduced new permissions for  blocks, core variables on CMS pages, templates and extensions. You can add your blocks in the admin section under System -> Permissions -> Blocks, or via setup scripts adding to the permission_block table.
Also, check if any other pages or blocks or transactional emails have been affected.

HostForLIFE.eu Magento Hosting
HostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24x7 access to their server and site configuration tools. Plesk completes requests in seconds. It is included free with each hosting account. Renowned for its comprehensive functionality - beyond other hosting control panels - and ease of use, Plesk Control Panel is available only to HostForLIFE's customers. They 
offer a highly redundant, carrier-class architecture, designed around the needs of shared hosting customers.



European Visual Studio 2017 Hosting - HostForLIFE.eu :: Drawing rubber-band lines and shapes in VB.NET

clock June 19, 2020 12:57 by author Peter

 The lack of XOR Drawing feature in GDI+ was not certainly welcome in the programmer's community. I guess it will be hard to survive with this handicap. In spite of this, I would like to show how we can draw rubber-band lines and shapes in GDI+ with just a few lines of code.

     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
    Dim size As Size = SystemInformation.PrimaryMonitorMaximizedWindowSize 
    bitmap = New Bitmap(size.Width, size.Height) 
    gB = Graphics.FromImage(bitmap) 
    Dim bckColor As Color = Me.BackColor 
    gB.Clear(bckColor) 
    End Sub 
    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.MouseEventArgs) 
    Dim p As Point = New Point(e.X, e.Y) 
    x0 = p.X 
    y0 = p.Y 
    drag = True 
    End Sub 
    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.MouseEventArgs) 
    Dim p As Point = New Point(e.X, e.Y) 
    x= p.X 
    y = p.Y 
    Dim cx As Integer = x - x0 
    Dim cy As Integer = y - y0 
    If drag Then 
    Dim gx As Graphics = CreateGraphics() 
    gx.DrawImage(bitmap, 0, 0) 
    gx.Dispose() 
    Dim g As Graphics = CreateGraphics() 
    Dim pen As Pen = New Pen(Color.Blue) 
    Select Case DrawMode 
    Case 1 
    g.DrawLine(pen, x0, y0, x, y) 
    Exit Select 
    Case 2 
    g.DrawEllipse(pen, x0, y0, cx, cy) 
    Exit Select 
    Case 3 
    g.DrawRectangle(pen, x0, y0, cx, cy) 
    Exit Select 
    End Select 
    g.Dispose() 
    pen.Dispose() 
    End If 
    End Sub 
    Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.MouseEventArgs) 
    Dim cx As Integer = x - x0 
    Dim cy As Integer = y - y0 
    Dim pen As Pen = New Pen(Color.Blue) 
    Select Case DrawMode 
    Case 1 
    gB.DrawLine(pen, x0, y0, x, y) 
    Exit Select 
    Case 2 
    gB.DrawEllipse(pen, x0, y0, cx, cy) 
    Exit Select 
    Case 3 
    gB.DrawRectangle(pen, x0, y0, cx, cy) 
    Exit Select 
    End Select 
    drag = False 
    pen.Dispose() 
    End Sub 
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.PaintEventArgs) 
    Dim gx As Graphics = CreateGraphics() 
    gx.DrawImage(bitmap, 0, 0) 
    gx.Dispose() 
    End Sub 
    Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)button1.ForeColor = Color.Red 
    button2.ForeColor = Color.Black 
    button3.ForeColor = Color.Black 
    DrawMode = 1 
    End Sub 
    Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
    button2.ForeColor = Color.Red 
    button1.ForeColor = Color.Black 
    button3.ForeColor = Color.Black 
    DrawMode = 2 
    End Sub 
    Private Sub button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
    button3.ForeColor = Color.Red 
    button1.ForeColor = Color.Black 
    button2.ForeColor = Color.Black 
    DrawMode = 3 
    End Sub 
    Private Sub panel1_Paint(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.PaintEventArgs) 
    button1.ForeColor = Color.Red 
    button1.Focus() 
    End Sub



European Entity Framework Hosting - HostForLIFE.eu :: Efficient Data Modification with Entity Framework Core

clock April 24, 2020 06:47 by author Peter

A simple rule says that for optimal performance, we need to make as few database requests as possible. This is especially relevant for insert and update scenarios, where we sometimes need to work with thousands of objects. Sending those objects to the database one by one is usually significantly slower than in a batch. With tools like Entity LINQ we can easily write efficient data modification queries.

Efficient Data Modification With Entity Framework Core 

Let's analyze the possible cases:
    INSERT
    UPDATE (DELETE)
    Upsert (UPDATE or INSERT)

INSERT case optimizations

Insert multiple rows in a single statement. Assuming we have a collection of promotions, the following snippet inserts them in a single query:
    public void InsertBatch(IEnumerable<Promotions> promos) 
    { 
        var query = DbContext.Promotions.Query((Promotions promo) => 
        { 
            var set = [email protected]((promo.PromotionName, promo.Discount, promo.StartDate, promo.ExpiredDate)); 
     
            INSERT().INTO(set); 
            var r = OUTPUT(INSERTED<Promotions>()); 
            VALUES(set.RowsFrom(promos)); 
     
            return r; 
        }); 
     
        foreach (var promo in query) 
            Console.WriteLine((promo.PromotionId, promo.PromotionName, promo.Discount, promo.StartDate, promo.ExpiredDate)); 
    } 


INSERT INTO ... SELECT ...
 
This is a so-called bulk insert. In the case that the data is already in the database, it is much cheaper to avoid data pulling altogether. The operation can potentially be performed inside the database. The following snippet copies addresses from one table to another according to some criteria without a single byte to leave the database.
    var cities = new[] { "Santa Cruz", "Baldwin" }; 
     
    DbContext.Database.Query((Stores stores, Addresses address) => 
    { 
        var set = [email protected]((address.Street, address.City, address.State, address.ZipCode)); 
     
        INSERT().INTO(set); 
        SELECT((stores.Street, stores.City, stores.State, stores.ZipCode)); 
        FROM(stores); 
        WHERE(cities.Contains(stores.City)); 
    }); 


UPDATE case optimizations

A bulk update works when there is a need to update multiple rows in the same table. There is a special SQL construct for this case - UPDATE ... WHERE, which performs the update in a single query. Some databases, like SQL server, also support a more powerful UPDATE ... JOIN construct. Below we update all the tax configurations without pulling them to the application server:
    var one = 0.01M; 
    var two = 0.02M; 
    DbContext.Database.Query((Taxes taxes) => 
    { 
        UPDATE(taxes).SET(() => { 
                taxes.MaxLocalTaxRate += two; 
                taxes.AvgLocalTaxRate += one; 
            }); 
        WHERE(taxes.MaxLocalTaxRate == one); 
    }); 


Bulk delete, same idea for the delete case.

    private static void PrepareProductHistory(Products products) 
    { 
        var productHistory = ToTable<Products>(PRODUCT_HISTORY); 
     
        SELECT(products).INTO(productHistory); 
        FROM(products); 
     
        Semicolon(); 
    } 
     
    ... 
     
    var year = 2017; 
    DbContext.Database.Query((Products products) => 
    { 
        PrepareProductHistory(products); 
        var productHistory = ToTable<Products>(PRODUCT_HISTORY); 
     
        DELETE().FROM(productHistory); 
        WHERE(productHistory.ModelYear == year); 
    }); 


UPSERT optimization
Efficient Data Modification With Entity Framework Core
 
Upsert means UPDATE or INSERT in a single statement. In cases when a table has more than 1 unique constraint (in addition to PK), plain INSERT can fail on duplicate key. In those cases, we usually want to ignore, replace or combine some existing fields with new values. Most vendors support this capability, but using different syntax and providing different features.
 
MERGE
SQL Server and Oracle. In fact, this is the official standard. In its simplest form, it allows for the specification of what to do WHEN MATCHED, i.e. when there is a unique key collision, and what to do WHEN NOT MATCHED, i.e. we can INSERT safely.

    DbContext.Category.Query((Category category) =>   
    {   
        var staging = ToTable<Category>(CATEGORY_STAGING);   
       
        MERGE().INTO(category).USING(staging).ON(category == staging);   
       
        WHEN_MATCHED().THEN(MERGE_UPDATE().SET(() =>   
                {   
                    category.CategoryName = staging.CategoryName;   
                    category.Amount = staging.Amount;   
                }));   
       
        var set = [email protected]((category.CategoryId, category.CategoryName, category.Amount));   
        WHEN_NOT_MATCHED().THEN(MERGE_INSERT(set.ColumnNames(), VALUES(set.RowFrom(staging))));   
       
        Semicolon();   
       
        return SelectAll(category);   
    });    

As the picture says, it's trickier than it should be. There are many tutorials and official documentation.
 
INSERT ... ON DUPLICATE ... - MySQL and Postgres. The syntax is much simpler and allows us to handle the most common case only (compared to feature-packed MERGE):

    // There is a store which might already exist in the database. 
    // Should we add it or update? (PK is not always the only UNIQUE KEY) 
    newOrExisting.LastUpdate = DateTime.Now; 
     
    DbContext.Database.Query((Store store) => 
    { 
        var view = [email protected]((store.StoreId, store.AddressId, store.ManagerStaffId, store.LastUpdate)); 
        INSERT().INTO(view); 
        VALUES(view.RowFrom(newOrExisting)); 
        ON_DUPLICATE_KEY_UPDATE(() => store.LastUpdate = INSERTED_VALUES(store.LastUpdate)); 
    }); 

Batch/bulk updates are usually in the order of a magnitude faster than working with entities one by one. Optimizing those scenarios is usually an easy improvement.



SQL Server 2016 Hosting - HostForLIFE.eu :: Subqueries And Correlated Subqueries

clock April 15, 2020 09:53 by author Peter

Subqueries In SQL Server
Subqueries are enclosed in parentheses. Subquery is also called an inner query and the query which encloses that inner query is called an outer query. Many times subqueries can be replaced with joins.
select * from Employee where DepartmentID not in (select distinct DepartmentID from Department) 

Another example:
select Department_Name,(select count(*) from Employee where DepartmentID=d.DepartmentID) from Department as d; 

The above query is an example of using subquery in the select list. The above result can be achieved using join also; see the below query
select d.Department_Name,COUNT(e.empid) as empcount from Department d 
join Employee e on e.DepartmentID=d.DepartmentID 
group by d.Department_Name 
order by empcount; 


According to MSDN, you can nest up to 32 levels.

Columns present in subqueries cannot be used in the outer select list of a query.

Correlated Subqueries

If our subquery depends on the outer query for its value then it is called a Correlated Subquery. It means subquery depends on outer subquery. Correlated subqueries are executed for every single row executed by outer subqueries.

A correlated subquery can be executed independently,
select distinct Department_Name,(select count(*) from Employee where DepartmentID=d.DepartmentID group by DepartmentID) as empcount from Department as d order by empcount; 

What to choose for performance --  Subquery or Join?
According to MSDN, there is no big difference between queries that use sub-queries and joins.

But in some cases, we need to check the performance, and Join produces better performance because the nested query must be processed for each result of the outer query. In such cases, JOIN will perform better.

In general, JOIN works faster as compared to subqueries but in reality, it will depend on the execution plan generated by the SQL Server. If the SQL server generates the same execution plan then you will get the same result.



Magento Hosting - HostForLIFE.eu :: How to Getting A Products URL on Magento?

clock April 3, 2020 08:14 by author Peter

In this post, I will show you how to get a products URL on Magento. There is 3 methods you can use, all of which are in Mage_Catalog_Model_Product. And here is the code:
public function getUrlPath($category=null)
public function getUrlInStore($params = array())
public function getProductUrl($useSid = null)

The simplest way to explain is to just show the results of many calls. Given a product whose URL key is scott-large-coffee-table-set-multicolour upon the domain of http :// created. local the results are :
$product->getUrlPath();
    'scott-large-coffee-table-set-multicolour'
$product->getUrlPath($category);
    'tables/scott-large-coffee-table-set-multicolour'
// you cannot stop this method adding ___store to the URL, even by setting _store_to_url to false
$product->getUrlInStore();
    'http://made.local/tables/scott-large-coffee-table-set-multicolour?___store=default'
// you cannot stop this method adding ___store to the URL, even by setting _store_to_url to false
// note - see the "using _ignore_category" section below for an arguable bug with using this param
$product->getUrlInStore(array('_ignore_category' => true));
    'http://made.local/scott-large-coffee-table-set-multicolour?___store=default'
$product->getProductUrl();
    'http://made.local/tables/scott-large-coffee-table-set-multicolour'
$product->getProductUrl(true);
    'http://made.local/tables/scott-large-coffee-table-set-multicolour'


To discover what some other params could be passed to getUrlInStore (), notice URL Route Parameters. Using _ignore_category. The brief version, I wouldn't use this param, and rather use Mage: getUrl ($product-getUrlPath ())

In case you first fetch a products URL that contains the category, then use a similar product instance to commit to fetch a non-category URL, you'll rather both times obtain a URL that includes the category, begin to see the below code :
$product = Mage::getModel('catalog/product');
$product->getUrlInStore();
    'http://made.local/sofas/peter-2-seater-sofa-blue?___store=default'
$product->getUrlInStore(array('_ignore_category' => true));
    'http://made.local/sofas/peter-2-seater-sofa-blue?___store=default'
$product = Mage::getModel('catalog/product');
$product->getUrlInStore(array('_ignore_category' => true));
    'http://made.local/peter-2-seater-sofa-blue?___store=default'

The problem lies using the request_path key upon the $product model, that the Mage_Catalog_Model_Product_Url : : getUrl () sets, to become a cached worth for an otherwise intensive method of resolving a URL rewrite to an item inside a category.

To solve this, unset request_path first, as beneath :
$product->unsRequestPath();
$product->getUrlInStore(array('_ignore_category' => true));
    'http://made.local/peter-2-seater-sofa-blue?___store=default'

Note which any technique outlined in the top of the card that leads to the category to be present inside the returned URL can have a similar effect of caching the category.

 



European Entity Framework Hosting - HostForLIFE.eu :: Eager Loading In Repository Pattern Entity Framework Core

clock February 28, 2020 11:08 by author Peter

Eager loading is the process whereby a query for one type of entity also loads related entities as part of the query, so that we don't need to execute a separate query for related entities.

In simple language, Eager loading joins the entities which have foreign relation and returns the data in a single query.

Now, the question is how to properly handle the eager-loading problem for complex object graphs within the Repository pattern.

Let's get started.

Step 1:  Add a method into your Interface which eager loads the entities which we specify:
  public interface IProjectInterface<T> where T : class 
  { 
  Task<IEnumerable<T>> EntityWithEagerLoad(Expression<Func<T, bool>> filter,                string[] children); 
  Task<List<T>> GetModel(); 
  T GetModelById(int modelId); 
  Task<bool> InsertModel(T model); 
  Task<bool> UpdateModel(T model); 
  Task<bool> DeleteModel(int modelId); 
  void Save(); 
  }


The method EntityWithEagerLoad() takes 2 arguments, one is filter criteria and another is an array of entities which we want to eager load.

Step 2: Define the method EntityWithEagerLoad in your base repository:
  public async Task<IEnumerable<T>> EntityWithEagerLoad(Expression<Func<T, bool>> filter, string[] children) 
  { 
              try 
              { 
                  IQueryable<T> query = dbEntity; 
                  foreach (string entity in children) 
                  { 
                      query = query.Include(entity); 
   
                  } 
                  return await query.Where(filter).ToListAsync(); 
              } 
              catch(Exception e) 
              { 
                  throw e; 
              }


Step 3 : For using this method , call this function from your controller as shown  below:
  [HttpGet] 
         [Route("api/Employee/getDetails/{id}")] 
         public async Task<IEnumerable<string>> GetDetails([FromRoute]int id) 
         { 
             try 
             { 
        var children = new string[] { "Address", “Education” }; 
   
        var employeeDetails=await _repository.EntityWithEagerLoad (d => d.employeeId==id, 
        children); 
   
             } 
             catch(Exception e) 
             { 
                 Throw e;             
             }


The variable employeeDetails contains employee details with their Address and education details.



Angular.js Hosting UK - HostForLIFE.eu :: Create Web Workers In Angular

clock February 14, 2020 08:29 by author Peter
In this article, we'll learn how to use web workers in Angular 8/9.

Web Workers
Web workers speed up in your application when we start working on CPU-intensive tasks. They let you offload work to a background thread. Once we allow a web worker to run, we can use it normally in our application, and the Angular cli will be able to split bundle and code.

The Following Browser versions which are supported in web workers:

  • Firefox: 3.5
  • Chrome: 4
  • Safari: 4
  • IE:10
  • Opera: 10.6

Installing AngularCLI
Let’s get started by installing Angular CLI, which is the official tool for creating and working with Angular projects. Open a new terminal and run the below command to install Angular CLI.

npm install -g @angular/cli.

If you want to install Angular 9, simply add @next
npm install --g @angular/[email protected]

Please check the below command for the Angular version.
ng version

Steps to follow:
Step 1
Create an Angular project setup using the below command or however you want to create it.
ng new projectname
 
Example,
ng new webworker

Step 2
Now, we must generate web workers from our Angular cli. Open a new terminal and run the below command.
ng generate webWorker my-worker
 
Create Web Workers In Angular 8/9
 
Step 3
Now, Create a Web Worker Object in App.component.ts(main scripts)
    const worker = new Worker ('./my-worker.worker', {type: 'module'});  

We can do some code in App.component.ts (main scripts)
    if (typeof Worker !== 'undefined') { 
        // Create a new 
        const worker = new Worker('./my-worker.worker', { 
            type: 'module' 
        }); 
        worker.onmessage = ({ 
            data 
        }) => { 
            console.log(`page got message: ${data}`); 
        }; 
        worker.postMessage('welcome'); 
    } else { 
        console.log('Web Workers are not supported in this environment.'); 
        // Web Workers are not supported in this environment. 
        // You should add a fallback so that your program still executes correctly. 
    } 


Step 4
Now, we can do some code in my-worker.worker.ts
    addEventListener('message', ({ 
        data 
    }) => { 
        const response = `worker response to ${data}`; 
        postMessage(response); 
    });  

    Web Workers are supported in the browser
    Create a new worker (main scripts).
    Post message to the worker in my-worker.worker.ts.
    When the worker gets the message, addEventListener will fire, and it will create a response to the object then it will call postMessage method.

Step 5
Now, run the application.
npm start

Step 6
Now, we will get the following output,



Drupal 8.8.1 CMS Hosting - HostForLIFE.eu :: How to Create an Image Style Programatically from Module

clock January 30, 2020 11:26 by author Peter

Today, I'm gonna tell you how to create an image style programatically from Drupal Module. You can use this in a .install file to create the needed image style when the module is installed.

The code below will allow you to create an image style from within a module programatically:

<?php
  $style = image_style_save(array('name' => 'avatar'));
  $effect = array(
    'name' => 'image_scale',
    'data' => array(
      'width' => 64,
      'height' => 64,
      'upscale' => TRUE,
    ),
    'isid' => $style['isid'],
  );
  image_effect_save($effect);
?>

This code below shows how to remove the image style:

<?php
  image_style_delete(image_style_load('avatar'));
?>

Hope this will works for you.

Drupal CMS with Free ASP.NET Hosting
Try our Drupal CMS with Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc. You will not be charged a cent for trying our service for the next 3 days. Once your trial period is complete, you decide whether you'd like to continue.



Ajax Hosting UK - HostForLIFE.eu :: How to call ASP.NET Page Method using jQuery AJAX ?

clock January 21, 2020 11:25 by author Peter

jQuery may be a powerful JavaScript library that permits you to call ASP.NET page method directly without any postback. you can call page method while not involving ScriptManager at all.

Creating page method:
First we've got to make page method, it ought to be declared as static with the [WebMethod] attribute.    [WebMethod]
    public static string GetDate()
    {
        return DateTime.Now.ToString();
    }

jQuery.ajax method:
           $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Default.aspx/MethodName",
                    data: "{}",
                    dataType: "json",
                    success: function (msg) {
                       //do something
                    }
                });

Type: the type of request the type ("POST" or "GET")
URL: A string containing the URL to that the request is sent.
ContentType: By default we've got to use "application/x-www-form-urlencoded; charset=UTF-8", when we sending information to server we've got to use this content type, that is okay for many cases.
Data: data send to be server, if data isn't a string it’ll be converted to query string.
DataType: the type of data that you are expecting back from the server.

Source code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>jQuery AJAX call</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            // Add the page method call as an onclick handler for the div.
            $('#btnGetTime').click(function () {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Default.aspx/GetDate",
                    data: "{}",
                    dataType: "json",
                    success: function (msg) {
                        alert('Current Time is ' + msg.d);
                    }
                });
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="button" id="btnGetTime" value="Get Time" />
    </div>
    </form>
</body>
</html>

C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    [WebMethod]
    public static string GetDate()
    {
        return DateTime.Now.ToString();
    }
}

Output:

HostForLIFE.eu AJAX Hosting
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 customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



DotNetNuke Hosting - HostForLIFE.eu : Forgot Your DNN Password?

clock December 5, 2019 11:47 by author Peter

I found myself having to access as administrator a site built with DotNetNuke Hosting without knowing the password or being able to reach the person who created it. What was I to do?

 

1. Create a new website (I am using C# here) in Visual Studio

2. Inside the web.config file, add the machineKey tag and provide “validationKey” and “decryptionKey” as found from web.config file of your running DNN site using which passwords are stored. (The keys provided here will work with the password as given in step)

<machineKey validationKey="5D47DA8BBE8C9D02378BC3360FD6724A43C69016" decryptionKey="F5292CB499D6A71955A7B389BFBF3712D0A48D1971DEE889" decryption="3DES" validation="SHA1" >

3. Create a new class and name it, “RecoverPassword.cs”

 using System; 
 using System.Configuration.Provider; 
 using System.Text; 
 using System.Web.Security; 
 public class RecoverPassword : MembershipProvider { 
   //Create a static instance of this class as a singelton  
   private static readonly RecoverPassword _instance = new RecoverPassword(); 
   public override MembershipPasswordFormat PasswordFormat { 
     get { 
       return MembershipPasswordFormat.Encrypted; 
     }   
   }  
   public static string RecoverEncryptedString(string target)   
   {     
     try     
     {       
       // Decode the password in Base64       
       byte[] data = Convert.FromBase64String(target); 
       //Get advantage of the DecryptPassword method 
       byte[] decryptedPassword = _instance.DecryptPassword(data); 
       string encodedPassword = Encoding.Unicode.GetString(decryptedPassword); 
       // Remove the salt value prepended to the value 
       // Salt value doesn''t do anything more than being appended to thte password string, just strip it out 
       return encodedPassword.Substring(8); 
     } 
     catch (ProviderException ex) 
     { 
       throw ex; 
     } 
   } 
   public override string ApplicationName 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
     set 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool ChangePassword(string username, string oldPassword, string newPassword) { 
     throw new NotImplementedException(); 
   } 
   public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string 
 newPasswordAnswer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, 
 bool isApproved, object providerUserKey, out MembershipCreateStatus status) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool DeleteUser(string username, bool deleteAllRelatedData) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool EnablePasswordReset 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool EnablePasswordRetrieval 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override int GetNumberOfUsersOnline() 
   { 
     throw new NotImplementedException(); 
   } 
   public override string GetPassword(string username, string answer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser GetUser(string username, bool userIsOnline) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) 
   { 
     throw new NotImplementedException(); 
   } 
   public override string GetUserNameByEmail(string email) 
   { 
     throw new NotImplementedException(); 
   } 
   public override int MaxInvalidPasswordAttempts 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int MinRequiredNonAlphanumericCharacters 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int MinRequiredPasswordLength 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int PasswordAttemptWindow 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override string PasswordStrengthRegularExpression 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool RequiresQuestionAndAnswer 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool RequiresUniqueEmail 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override string ResetPassword(string username, string answer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool UnlockUser(string userName) 
   { 
     throw new NotImplementedException(); 
   } 
   public override void UpdateUser(MembershipUser user) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool ValidateUser(string username, string password) 
   { 
     throw new NotImplementedException(); 
   } 
 }

4. Copy paste the following code inside the above created class. This way we inherit our class from aspnet membership provider pattern class and thus will use its decryption procedure to decrypt the passwords. If you want to do that manually, do remember that Ctrl+K+M is a nice shortcut to implement base class methods which saves quite an effort from your end.

 using System; 
 using System.Configuration.Provider; 
 using System.Text; 
 using System.Web.Security; 
 public class RecoverPassword : MembershipProvider { 
   //Create a static instance of this class as a singelton  
   private static readonly RecoverPassword _instance = new RecoverPassword(); 
   public override MembershipPasswordFormat PasswordFormat { 
     get { 
       return MembershipPasswordFormat.Encrypted; 
     }   
   }  
   public static string RecoverEncryptedString(string target)   
   {     
     try     
     {       
       // Decode the password in Base64       
       byte[] data = Convert.FromBase64String(target); 
       //Get advantage of the DecryptPassword method 
       byte[] decryptedPassword = _instance.DecryptPassword(data); 
       string encodedPassword = Encoding.Unicode.GetString(decryptedPassword); 
       // Remove the salt value prepended to the value 
       // Salt value doesn''t do anything more than being appended to thte password string, just strip it out 
       return encodedPassword.Substring(8); 
     } 
     catch (ProviderException ex) 
     { 
       throw ex; 
     } 
   } 
   public override string ApplicationName 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
     set 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool ChangePassword(string username, string oldPassword, string newPassword) { 
     throw new NotImplementedException(); 
   } 
   public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string 
 newPasswordAnswer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, 
 bool isApproved, object providerUserKey, out MembershipCreateStatus status) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool DeleteUser(string username, bool deleteAllRelatedData) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool EnablePasswordReset 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool EnablePasswordRetrieval 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) 
   { 
     throw new NotImplementedException(); 
   } 
   public override int GetNumberOfUsersOnline() 
   { 
     throw new NotImplementedException(); 
   } 
   public override string GetPassword(string username, string answer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser GetUser(string username, bool userIsOnline) 
   { 
     throw new NotImplementedException(); 
   } 
   public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) 
   { 
     throw new NotImplementedException(); 
   } 
   public override string GetUserNameByEmail(string email) 
   { 
     throw new NotImplementedException(); 
   } 
   public override int MaxInvalidPasswordAttempts 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int MinRequiredNonAlphanumericCharacters 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int MinRequiredPasswordLength 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override int PasswordAttemptWindow 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override string PasswordStrengthRegularExpression 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool RequiresQuestionAndAnswer 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override bool RequiresUniqueEmail 
   { 
     get 
     { 
       throw new NotImplementedException(); 
     } 
   } 
   public override string ResetPassword(string username, string answer) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool UnlockUser(string userName) 
   { 
     throw new NotImplementedException(); 
   } 
   public override void UpdateUser(MembershipUser user) 
   { 
     throw new NotImplementedException(); 
   } 
   public override bool ValidateUser(string username, string password) 
   { 
     throw new NotImplementedException(); 
   } 
 } 

5. Your default.ascx.cs file must be like this (Change the password in Page_Load with the password you want to decipher):

 using System; 
 public partial class _Default : System.Web.UI.Page { 
   protected void Page_Load(object sender, EventArgs e)     
   { 
      //This password can be obtained from the DNN''s table aspnet_Membership column "Password"    
      //Or you can query ther datbase row and call decryption method for each user    
      string password = "vhicPWw3Eo/+z+mrKM5ZQCIcURj1O5Cq9Epw942lfpmsDPagupzLGw=="; 
     //Call our inherited class to get Decrypted Password    
     string recoveredPassword = RecoverPassword.RecoverEncryptedString(password); 
     //Write down the decrypted password       
    Response.Write(recoveredPassword);  
   } 
 } 

6. Right click > View in Browser and the password is decrypted on a fly.



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