adsense

Sunday, February 21, 2021

HTTP Error 500.52 - URL Rewrite Module Error

 When browsing website through IIS you might encounter the following error.

Website is not accessible: HTTP Error 500.52 - URL Rewrite Module Error 

Follow the below steps to resolve this issue.

  • open (IIS) Manager (in windows 10 type "inetmgr" in search windows
  • Navigate to Server name > Sites >your_website > URL rewrite
  • Select each rewrite rule and disable them (Right click  and disable)
  • Enable each rewrite rule (right click and clicking enable)

Cheers

Samitha


Tuesday, February 16, 2021

using carriage return in a HTML tooltip

 If you want to add a line break to HTML tooltip, just press ENTER at the end of each word. Ans example is shown.


<a href="#" title='This

tooltip

shows in

multiple

Lines'>link</a>

Saturday, January 30, 2021

Reset Linkedin link preview cache

 If you have shared your website or an article in LinkedIn and then you decided to change the link preview data then you will see that LinkedIn still displaying old content. This happens as e LinkedIn caches link preview data  for 7 days.

We can resolve this using the LinkedIn Post Inspector. Follow these steps to claerLinkedin link preview cache.

  1. Navigate tohttps://www.linkedin.com/post-inspector/
  2. Input your URL and click on Inspect. preview image will be updated
  3. Retry to share your URL on LinkedIn


 Cheers

Samitha


Tuesday, January 12, 2021

Textbox format number with two decimal places

 There can be many ways to display a number formatted in a textbox. Here I have used jQuery to achieve the expected result.


<script>

$(function () {

    $('#txtAmount').on('input', function(e) {

        if (/^(\d+(\.\d{0,2})?)?$/.test($(this).val())) {

            $(this).data('oldValue', $(this).val());

        } else {

            $(this).val($(this).data('oldValue') || '');

        }

    }).trigger('input');  

});

</script>

HTML

<input type="text"  id="txtAmount" placeholder="Enter Amount" />


Cheers

Samitha

Monday, December 14, 2020

Convert .net object into a JSON string

We can use JsonWriter to return a JSON representation of any .Net object as displayed below.


public class Person

    {

        public Int Id   {set ; get;}

        public String Name{set ; get;}

       public List<PhoneNumbers> Contacts{set ; get;}

         public String ToJSONRepresentation()

        {

            StringBuilder stringBuilder = new StringBuilder();

            JsonWriter jsonWriter = new JsonTextWriter(new StringWriter(stringBuilder));


            jsonWriter.Formatting = Formatting.Indented;

            jsonWriter.WriteStartObject();

            jsonWriter.WritePropertyName("id");

            jsonWriter.WriteValue(this.Id);

            jsonWriter.WritePropertyName("name");

            jsonWriter.WriteValue(this.Name);


            jsonWriter.WritePropertyName("phonenumbers");

            jsonWriter.WriteStartArray();


            int i=0;


            for (i = 0; i < Contacts.Count; i++)

            {

                jsonWriter.WriteStartObject();

                jsonWriter.WritePropertyName("homePhone");

                jsonWriter.WriteValue(addresses[i].homePhone);

                jsonWriter.WritePropertyName("workPhone");

                jsonWriter.WriteValue(addresses[i].workPhone);

                jsonWriter.WritePropertyName("mobilePhone");

                jsonWriter.WriteValue(addresses[i].mobilePhone);

                jsonWriter.WriteEndObject();

            }

            jsonWriter.WriteEndArray();

            jsonWriter.WriteEndObject();

            return stringBuilder.ToString();

        }

      }

}


Cheers

Samitha

Friday, November 20, 2020

SQL get specific element Count in XML

 Consider this XML


Suppose you want to get count of student ids. You can use SQL to get the count as follows.

declare @xml XML;

set @xml ='<Students>

    <Student>

        <Id>001</Id>

        <Fname>Leesa</Fname>

        <Sname>Humpry</Sname>

    </Student>

    <Student>

        <Id>002</Id>

        <Fname>Clara</FName>

        <Sname>Margrette</Sname>

    </Student>

  </Students>';

select @xml.value('count(/Students/Student/Id)', 'INT') AS 'Count'

Cheers

Samitha

Sunday, November 8, 2020

sql server remove duplicates from query

You can use SQL row_number() function to remove duplicate rows from a query.

Create table Employees (fname varchar(100), lname varchar(100))

Insert into Employees Values 
               ('Tim', 'May')
             , ('Clara', 'Magrette') 
             , ('Clara', 'Magrette')
             , ('Jeff', 'Lawry') 
             , ('Brian', 'Adams')
             , ('Paul', 'Oliver')

As you can see there are duplicate records in the Employees table,

Select * from(
SELECT fname 
       ,lname 
       ,row_number() over (partition by fname , lname order by fname , lname ) as rownum 
FROM Employees 
) result
where rownum= 1 -- selects DISTINCT Employees only

Cheers,
Samitha