Login failed for user IIS APPPOOL\AppPool4.5 or APPPOOL\ASP.NET

0 comments


The error ‘Login failed for user 'IIS APPPOOL\AppPool4.5’ usually occurs when you configure a new website in IIS or move an existing website to a newer version of IIS.

A simple solution to the error is to add a login to SQL Server for IIS APPPOOL\ASP.NET v4.5 and grant appropriate permission to the database.

Open SQL Server Management Studio > Right click ‘Security’ > New > Login

iis-apppool-login

Allowing dots in ASP.NET MVC paths

0 comments


URLs with a dot(.) in ASP.NET MVC generate a 404. I have seen many solutions on the web to solve this issue. Some of them are as follows:

1. Add the following handler to your web.config

<system.webServer>
<handlers>
<add name="ApiURIs-ISAPI-Integrated-4.0_2"
path="/products/*"
verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>


Here I am assuming that the url’s that contains dots in your case is starting from /products/urlwith.adot. A drawback is as soon as you set path to [path="*"] all requests to static files such as .pdf, .js, .css etc fails.

ASP.NET Project Image Paths

0 comments


I still see a lot of developers getting confused with the image paths in an ASP.NET application.

Here’s a very quick primer to help you with it:

Absolute Path

<img src="http://www.yourxyxwebsite.com/Images/SomeImage.jpg" />

Images folder in site root directory ("/")

<img src="/Images/SomeImage.jpg" />

Images folder in the current directory ("./")

<img src="./Images/SomeImage.jpg" />

./image.jpg and image.jpg are the same and refer to the current directory

HTML5 Video with Subtitles

1 comments



HTML5 video element allows us to create caption enabled video pages. Captions/subtitles allows media contents to reach to different geographical locations. For example, if the media contents are in English and need to be translated into French or German to reach an audience that speaks these languages. We can provide the subtitles in our HTML5 Video element in the favorite language of the user.

To provide subtitles in HTML 5 video element, we will make use of WebVTT and TTML format files. These files are simple text files.

1. WebVTT - Web Video Text Tracks

2. TTML - Timed Text Markup Language

Introduction to WebVTT


WebVTT [Web Video Text Tracks] is a simple text file with the extention .vtt. This file can contain different types of information. For example -

  • Subtitles - The translation of the speech/dialog based on time.
  • Captions - It is similar to subtitles but it can include sound effects or other information of the media.
  • Chapters - You can create chapters so that user can navigate through the video. For example, creating chapters based on a slide show of Power Point Presentation.
  • Metadata - Information about the video which you can access using scripting languages.

WebVTT files can also be captured using script languages. These files can be created manually or you can create them using some authoring tools. The format of the file is as shown here:


















The WebVTT file [.vtt], starts with WEBVTT. Then it includes the time which is from and to with the decoration/position of the text which you want to display on your media. The position is shown as A:middle, i.e. the center of the screen.

The next line is the dialog/speech to display on the media. These contents are known as "cues". Each "cue" starts with an ID which is 1, 2 in our case. It must be separated with a blank line. Time specification must be done in HH:MM:SS:MMM format.You can even style the cues using CSS. The above file is used for displaying French subtitles.

Introduction to TTML


TTML [Timed Text Markup Language] is a specification published by W3C. TTML is XML based language. TTML file includes the XML version and encoding type. The format of the file is shown here:



















The root element in this language starts with <tt> with a namespace. Then you include <body> and <div> tags. In the <div> tag, we are including cues. The timing is specified with the begin and end in the paragraph tag.

Compared to the VTT, the TTML format looks little complex. But when you start using it, you get familiar with it.

Microsoft provides a simple tool called Caption maker. You can visit the URL to download this tool http://ie.microsoft.com/testdrive/Graphics/CaptionMaker/

Now let's start creating our demo which will display the video in HTML 5 <Video> element and subtitle the same in English and French.

To start with, create a blank ASP.NET Web application and add a HTML page. I have named my HTML page as "MathsVideo.html".

Once you add the page, add a folder with the name "Media" under your web application and paste the video which you want to display. For more information about HTML 5 Video element media format support, please visit the link given below -

https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats

I am using the MP4 format for this demonstration. Once you add the media file into our Media folder, right click the Media folder and add a text file with the extension .vtt. I have named my file as "MathTrickSubtitle1_EN.vtt" and used the code shown below -

WEBVTT

1
00:00:01.000 --> 00:00:03.000 A:middle
 Let's say you want to multiply 12 x 13

2
00:00:04.000 --> 00:00:07.000 A:middle
 For this one we will draw one line

3
00:00:08.000 --> 00:00:15.000 A:middle
 For the two we will leave a little bit of space and will draw two lines

4
00:00:16.000 --> 00:00:23.000 A:middle
 For the other numbers we will draw the lines to the other direction

5
00:00:24.000 --> 00:00:29.000 A:middle
 Now we will group together different lines and will count the dots

6
00:00:30.000 --> 00:00:33.000 A:middle
  Here we have six different dots

7
00:00:34.000 --> 00:00:37.000 A:middle
  In the middle, we have 5 different dots

8
00:00:38.000 --> 00:00:41.000 A:middle
  And on the other side we have one dot

9
00:00:42.000 --> 00:00:44.000 A:middle
   And that's the anser - 156

Now let's repeat the above steps to add French subtitles. I have named my file as " MathTrickSubtitle1_EN.vtt ". The code is as shown below -

WEBVTT

1
00:00:01.000 --> 00:00:03.000 A:middle
 Disons que vous voulez multiplier 12 x 13

2
00:00:04.000 --> 00:00:07.000 A:middle
 Pour celui-ci nous allons tirer une ligne

3
00:00:08.000 --> 00:00:15.000 A:middle
 Pour les deux , nous allons laisser un peu d'espace et nous allons tracer deux lignes

4
00:00:16.000 --> 00:00:23.000 A:middle
 Pour les autres chiffres que nous allons tracer les lignes à l'autre direction

5
00:00:24.000 --> 00:00:29.000 A:middle
 Maintenant, nous allons regrouper les différentes lignes et comptera les points

6
00:00:30.000 --> 00:00:33.000 A:middle
  Ici, nous avons six points différents

7
00:00:34.000 --> 00:00:37.000 A:middle
  Au milieu , nous avons cinq points différents

8
00:00:38.000 --> 00:00:41.000 A:middle
  Et de l'autre côté nous avons un point


9
00:00:42.000 --> 00:00:44.000 A:middle
   Et ce est la anser - 156

I have used a translator to convert the English speech to French. That could be the reason, you may not see the correct word as per the speech.

Now open the Web.config file and write the code shown below. This code registers the MIME type for WebVTT and TTML. If you don't include this, you may not see the subtitles in our video.

<system.webServer>
    <staticContent>
      <remove fileExtension=".vtt" />
      <mimeMap fileExtension=".vtt" mimeType="text/vtt" />
      <remove fileExtension=".ttml" />
      <mimeMap fileExtension=".ttml" mimeType="application/ttml+xml" />
    </staticContent>
</system.webServer>

Now we will add a <video> element in our HTML page. The code for HTML is shown below -

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Video With Subtitles</title>
</head>
<body>
    <video controls="controls" src="../Media/MathTrick1.mp4">
        <track kind='subtitles' srclang='en' label='English' src='../Media/MathTrickSubtitle1_EN.vtt' default>
        <track kind='subtitles' srclang='fr' label='French' src='../Media/MathTrickSubtitle1_FR.vtt'>
    </video>
</body>
</html>

In the above code we are using <video> element and the <track> element inside the video element. The <track> element contains several attributes like - kind - You can set the value of this attribute like captions, chapters, descriptions, metadata and subtitles. We are using subtitles. srclang is set to en and fr respectively. The label and the path of the source file. We are also making English as a default subtitle. User can change the same as per his/her choice.

Now let's run the web page and see how your subtitles look like. The output is shown here:





























Now if you change the language to French using the label shown above, you will see French subtitles. It is shown here:





























Now let's test the same using TTML [Timed Text Markup Lanague] file. Let's first add a text file with the extension, .ttml into our Media folder. I have named it as "MathTrickSubtitle2_EN.ttml". Write the code shown below in the file -

<?xml version="1.0" encoding="UTF-8"?>

<tt xmlns="http://www.w3.org/ns/ttml" xml:lang="en" >
  <body>
    <div>
      <p begin="00:00:01.000" end="00:00:03.000">Let's say you want to multiply 12 x 13. </p>
      <p begin="00:00:04.000" end="00:00:07.000">For this one we will draw one line. </p>
      <p begin="00:00:08.000" end="00:00:15.000">For the two we will leave a little bit of space and will draw two lines. </p>
      <p begin="00:00:16.000" end="00:00:23.000">For the other numbers we will draw the lines to the other direction. </p>
      <p begin="00:00:24.000" end="00:00:29.000">Now we will group together different lines and will count the dots. </p>
      <p begin="00:00:30.000" end="00:00:33.000">Here we have six different dots. </p>
      <p begin="00:00:34.000" end="00:00:37.000">In the middle, we have 5 different dots. </p>
      <p begin="00:00:38.000" end="00:00:41.000">And on the other side we have one dot. </p>
      <p begin="00:00:42.000" end="00:00:44.000">And that's the anser - 156. </p>
    </div>
  </body>
</tt>

Now let's add another text file with the .ttml extsion into our Media folder. I have named the file as "MathTrickSubtitle2_FR.ttml". Write the code shown below in the file -

<?xml version="1.0" encoding="UTF-8"?>

<tt xmlns="http://www.w3.org/ns/ttml" xml:lang="en" >
  <body>
    <div>
      <p begin="00:00:01.000" end="00:00:03.000">Disons que vous voulez multiplier 12 x 13</p>
      <p begin="00:00:04.000" end="00:00:07.000">Pour celui-ci nous allons tirer une ligne</p>
      <p begin="00:00:08.000" end="00:00:15.000">Pour les deux , nous allons laisser un peu d'espace et nous allons tracer deux lignes</p>
      <p begin="00:00:16.000" end="00:00:23.000">Pour les autres chiffres que nous allons tracer les lignes à l'autre direction</p>
      <p begin="00:00:24.000" end="00:00:29.000">Maintenant, nous allons regrouper les différentes lignes et comptera les points</p>
      <p begin="00:00:30.000" end="00:00:33.000">Ici, nous avons six points différents</p>
      <p begin="00:00:34.000" end="00:00:37.000">Au milieu , nous avons cinq points différents</p>
      <p begin="00:00:38.000" end="00:00:41.000">Et de l'autre côté nous avons un point</p>
      <p begin="00:00:42.000" end="00:00:44.000">Et ce est la anser - 156</p>
    </div>
  </body>
</tt>

Now it's time to change the source of the file into our HTML page. The code for HTML page is as shown below -

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Video With Subtitles</title>
</head>
<body>
    <video controls="controls" src="../Media/MathTrick1.mp4" height="400" width="500">
        <track kind='subtitles' srclang='en' label='English' src='../Media/MathTrickSubtitle2_EN.ttml' default>
        <track kind='subtitles' srclang='fr' label='French' src='../Media/MathTrickSubtitle2_FR.ttml'>
    </video>
</body>
</html>

Now run your web page and see the output. It will be same as shown above. I have done a test of WebVTT which is supported by IE 10, Google Chrome 18, Firefox. TTML is supported by IE 10. But I didn't find the support for the same in Google Chrome 39.0 and Firefox 33.

Summary - In this article, we have seen how to display subtitles using HTML 5 video element. We have seen WebVTT and TTML file formats to create the subtitles and embed them using a <track> element.

C# (Csharp) Switch Case Statement with Example

0 comments


A C# switch case statement defines multiple groups of statements, and then executes one of these statement; depending on the value of a constant or test expression.

Let us understand this concept with an example.

string siteName = "DevCurry";
switch (siteName) {
    case "DotNetCurry":
    Console.WriteLine("This website is DotNetCurry.com");
    break;

    case "DevCurry":
    Console.WriteLine("This website is DevCurry.com");
    break;

    default:
    Console.WriteLine("Default Website");
}

As you can see, we start by defining a constant at the top:

Maximum size of the Web.config file

2 comments


The maximum size of the web.config file is 250KB. This file size has a limit set on it to prevent Denial Of Service (DoS) attacks as well as to keep the file manageable.

In one of the production environments running Windows Server 2003 R2, this file size went upto 300KB. When the team migrated the app to run on Windows Server 2008 R2 and IIS 7.5, they received an error “cannot read configuration file because it exceeds the maximum file size”.

The issue was resolved by changing a registry key.

HKLM\SOFTWARE\Wow6432Node\Microsoft\InetStp\Configuration\MaxWebConfigFileSizeInKB (REG_DWORD)

Make sure to restart the process once the key is updated.

Remove Vertical Scrollbars in SyntaxHighlighter

0 comments


SyntaxHighlighter created by Alex Gorbatchev is a code syntax highlighter developed in JavaScript. It basically makes your code snippets beautiful.

Many a times even when not required, a vertical scroll gets added to your code as shown here:

syntax-highlighter-scroll

The scroll appears in some browsers (especially Chrome) as the default style set in shCoreDefault.css is overflow: auto. If you do not want a vertical scrollbar, you can always do this:

Troubleshooting your ASP.NET Environment to Run AJAX in IIS 7.5

0 comments


After you have created that ASP.NET website of yours and are ready to deploy it on your server (home, company or hosting), you may soon realize that you cannot run any of the AJAX examples (especially in Chrome browser) without using a web server like IIS. You may also require some additional configuration in IIS to run ASP.NET code.

Follow these steps to make sure that you set up your Environment appropriately to run ASP.NET websites on IIS. I am using IIS 7.5 on a Windows 7 machine with Visual Studio 2012. The same process will work even for Visual Studio 2010 with ASP.NET 4.0.

Step 1: The first step is to make sure IIS is installed on your machine. Go to the Control Panel\Programs\Programs and Features and click ‘Turn Windows Features on or off’. This brings up a Windows Features list. Check the ‘Internet Information Services’ checkbox if it is unchecked
 

Copyright © 2009-2015 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions