Showing posts with label Technical. Show all posts
Showing posts with label Technical. Show all posts

Wednesday, April 3, 2019

Validation of viewstate MAC failed.

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

This error is usually caused by the asp.net worker process or the server recycling. By default, ASP.NET encrypts the viewstate using an Autogenerated Key when the process spins up. The problem comes when a client (browser) sends the request with a viewstate encrypted with the key generated by another worker process. Since the key is different, ASP.NET will not be able to decrypt the viewstate and it will throw the above error.

There are several ways to get around this problem:

1) Host your site on a server where the application pools never recycle! Obviously, this is impossible in Shared Hostings. You need a VPS server or dedicated server, where you can configure your own settings.

2) Disable ViewstateMac by putting this “enableViewStateMac="false"” in your web.config. This approach is not 100% secure.

3) Configure ASP.NET to not use Auto-Generated Key but rather a predefined key. This is the preferred method. 

To do this, follow these steps:

a) Either build your own Key Generator (https://support.microsoft.com/en-us/help/313091or use this tool (http://www.allkeysgenerator.com/Random/ASP-Net-MachineKey-Generator.aspx). I highly recommend you use the online tool. So assuming you will use the online tool:

b) In the online tool, simply click on “Generate”. 

c) Copy the content in the textbox into your site’s web.config file. The machineKey node should be within <system.web>

eg.

<?xml version="1.0"?>

<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<machineKey 
validationKey="2EEA416CEFC6D6BE856ED57B97FB9CA7DFACE17C073125949A1D682C80A44BB2AD887DDDC13DBFB0954F1000FEE5757E99693F222F8E28CAA2E6DAB8C4F99E0C" decryptionKey="877478B2F33A74226ABEF55FDCC1A76E43F1BBEA6241A592" validation="SHA1" />
<compilation debug="false"/>
<authentication mode="Windows"/>
<pages enableViewStateMac="true"/>
</system.web>
</configuration>

Thursday, July 19, 2018

How to enable the developer tab in excel 2010


 step 1-open the excel
 step 2- goto option from file tab
 step 3- click on the costomize ribbons
 step 4- check developer tab in main tab on right side
 step 5- click ok now develoer tab in enable.


Friday, April 27, 2018

Fibonacci Series in php

  This program print the fibonacci series.

<?php
//0 1 1 2 3 5 8 13 21 34
  class Fib {
     function printFib($n) {
        if($n==0) return 0;
        $a=0;$b=1;$c;
        echo $a." ".$b ;
        for($i=2;$i<=$n;$i++) {
        $c=$a+$b;
        $a=$b;
        $b=$c;
        echo $c." ";         
        }
     }
  }
 $fib=new Fib();
 $fib->printFib(5);
 ?>

output:

0 11 2 3 5

Thursday, April 26, 2018

Check wether a given string is Palindrome or not

<?php
class Palindrome
{
    public static function isPalindrome($word)
    {
       
    $string = str_replace(' ', '', $word);


    $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);

    $string = strtolower($string);

    $reverse = strrev($string);

    if ($string == $reverse) {
       return true;
    }
    else {
        return false;
    }
       
    }
}

echo Palindrome::isPalindrome('nitin');
?>

Wednesday, April 25, 2018

Difference between $variable and $$variable.


$variable is a normal variable $$variable takes the value of a variable and treats that as the name of a variable

<?php
 $var="Hello world";
 $$var1="var";
 echo $$var1;
?>
 outPut:
  Hello world
 
  Here:
  $var : Representa a variable.
  $$var1: Represents a variable with content of $var.

Wednesday, April 4, 2018

Print the text on image using GD library in php


GD library is a graphics drawing library that provides tools for manipulating image data. The GD library is used to process images for generating gallery preview and thumbnail size images automatically.

In php GD library provides the function for display the text on the images .
  The given example to show text data on the image using GD library.
 Certificate Image Before

<?php
$yourname = "Brijpal Singh";
$date = "01 Apr 2018";
$pos = "2018";
$rollNo="1003";
$day="Monday";
$month="Apr";
$year="18";
$fta="FTA";
$code="C001";
$startDate="2018";
$endDate="2020";
$dest = imagecreatefrompng('brij.png');//Link  Of Certificate Image
$src = imagecreatefromjpeg('th.jpg'); // Candidate Image (passport size);
imagealphablending($dest, false);

imagecopymerge($dest, $src, 100, 100, 0, 0, 130, 150, 100);
$red = imagecolorallocate($dest, 150,0, 0);
imagefttext($dest, 17, 0, 160, 72, $red, "open-sans/OpenSans-Regular.ttf", $rollNo);
imagefttext($dest, 17, 0, 1080,85, $red, "open-sans/OpenSans-Regular.ttf", $date);
imagefttext($dest, 20, 0, 540, 454, $red, "open-sans/OpenSans-Italic.ttf", $yourname);
imagefttext($dest, 17, 0, 750, 520, $red, "open-sans/OpenSans-Regular.ttf", $pos);
imagefttext($dest, 17, 0, 400, 585, $red, "open-sans/OpenSans-Regular.ttf", $day);
imagefttext($dest, 17, 0, 650, 585, $red, "open-sans/OpenSans-Regular.ttf", $month);
imagefttext($dest, 17, 0, 880, 585, $red, "open-sans/OpenSans-Regular.ttf", $year);
imagefttext($dest, 17, 0, 450, 645, $red, "open-sans/OpenSans-Regular.ttf", $fta);
imagefttext($dest, 17, 0, 880, 645, $red, "open-sans/OpenSans-Regular.ttf", $code);
imagefttext($dest, 17, 0, 500, 705, $red, "open-sans/OpenSans-Regular.ttf", $startDate);
imagefttext($dest, 17, 0, 980, 705, $red, "open-sans/OpenSans-Regular.ttf", $endDate);

// Output and free from memory
header('Content-Type: image/png');
imagepng($dest);

?>

Output:-





Tuesday, April 3, 2018

How to use one PHP class to Another php class


 Here i have create the 3 php files .

MyClass1.php

  <?php
  class MyClass1 {
   public $nm="brij";
}

?>


MyClass2.php
<?php
  class MyClass2 {
   public $nm="brij2";
}

?>

Test.php

<?php
spl_autoload_register(function ($class_name) {
    include $class_name . '.php';
});

$obj  = new MyClass1();
$obj2 = new MyClass2();
echo $obj->nm;
echo $obj2->nm;
?>

Saturday, March 31, 2018

Macro to convert bulk word file to html filtered file

Macro to convert bulk word file to html filtered file

Sub all_to_htm()
'
' all_to_htm Macro
'
'
 Dim directory As String
    directory = "Z:\mathmuni2\docs\2017-11-30" ' The starting directory
 
    Dim fso, newFile, folder, files
    Set fso = CreateObject("Scripting.FileSystemObject")
  
    Set folder = fso.GetFolder(directory)
    Set files = folder.files
  
    For Each file In files
      
        'MsgBox (file.ParentFolder)

        Dim newName As String
        newName = Replace(file.Name, ".docx", ".htm")
        'newName = Replace(file.path, ".docx", ".htm")
        Dim newPath As String
        newPath = directory + "\html_images\" + newName
      
      
      
        ChangeFileOpenDirectory directory
        Documents.Open FileName:= _
            file.path, _
            ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
            PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
            WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
            wdOpenFormatAuto, XMLTransform:=""
      
        ActiveDocument.SaveAs FileName:= _
            newPath, FileFormat:= _
            wdFormatFilteredHTML, LockComments:=False, Password:="", AddToRecentFiles _
            :=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
            :=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
            SaveAsAOCELetter:=False
        ActiveWindow.View.Type = wdWebView
        ActiveDocument.Close
      
    Next
End Sub

Friday, March 30, 2018

Difference between HTTP and HTTPS


* In HTTP, URL begins with "http://" whereas In HTTPS, URL starts with "https://".
* HTTP uses port number 80 fro communication and HTTPS uses 443.
* HTTP is consideres to be unsecure and HTTPS is secure.
* HTTP Works at Application Layer and HTTPS works at Transport Layer.
* In HTTP, Encryption is absent and Encryption is present in HTTPS.
* HTTP does not requie any certificates and HTTPS needs SSL certificates.
both of these are protocols using which the information of a particular website is exchanged between Web Server and Web Browser. But what’s difference between these two? Well, extra s is present in https and that makes it secure! What a difference  A very short and concise difference between http and https is that https is much more secure compared to http.

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...