Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

20 June, 2018

Deploying a Web Application using IIS, HTTP Error 401.3 Solved

IIS 7's redesigned management console
IIS 7's redesigned management console (Photo credit: Wikipedia)
Deploying a web application using IIS in Windows was a problem for me after I have completed the task of developing the web app. Publishing it is easy following the File System or FTP method. And there are many articles that you can find on the web telling the same thing.

So why doesn't the web application run right away?

Here's my application structure:
The simple web application I created used bootstrap and CSS, and some jQuery and Javascript functions. It uses some database tables running in MSSQL Express. Now if I remember, I have set up my MSSQL Express to run on mixed authentication mode.

I checked my connectionstring values, and everything seems to be in place. In fact, I am able to perform web application deployment smoothly. Only that I get into an error when I click on a page that accesses the database. Even just querying data and no transactions yet.

I asked a fellow developer, and I was told to add in a logger. That is to help me identify what wrong thing could be happening that isn't normally seen or shown.

But I didn't do that. I am already so close and getting impatient. All static pages working, and only those dependent on the database have issues. I was near to pulling my hair!

But my patience took the better of me. I continued searching, and I found some more articles, randomly, which I tried one by one.

That fixed the issue, and I was able to run the web application if full spectrum.

Here's what I have done, and hopefully, it would help others, too.

1. The usual web application deployment methods, but in my case, File System.
2. In particular, I get HTTP Error 401.3 - Unauthorized: Access is denied due to an ACL set on the requested resource.

Now remember, MSSQL Server was set up using mixed authentication mode, so I have sa account and also Windows account. The latter is the key. Windows account is not authorized, so database access fails.

What's the fix?

Open up IIS Manager (type 'inetmgr' in Cortana/search box).
Open up Sites, then click on the Web Site you are fixing.
In the middle pane, under IIS section, double-click on Authentication.
Right click on Anonymous Authentication, then select Edit.
Instead of Application pool identity, select now Specific user and specify IUSR (or IIS_IUSR).
(In some cases, selecting Application pool identity would do the trick.)
Click on Set and enter the credentials, if needed.
Then OK.

Now go back to the folder where the web site is deployed and give proper priveleges for the IUSR account. For my case, that is what fixed the problem. So I'm logging this discovery via my blog.

Anyway, if this doesn't work, it is 99.99% an issue of the account being used to access the database that is the cause, so just play around these settings. So much so if all static pages already work.

Hope it helps others, too.

Till then!

17 October, 2013

Stylesheet folder or directory - could make or break your web apps

English: CSS rule in Malayalam
English: CSS rule in Malayalam (Photo credit: Wikipedia)
17-October-2013

I have been reading on ASP.NET, so at least I learn something new. I have been coding and coding and coding, and I have become the woodcutter who did not sharpen his axe. And with the slowdown in load (all major projects completed, and pending roll-out only), I have some free time on my hand.

I found an e-book of Beginning ASP.NET 4.5 in C# and VB, and I skipped the chapters that discussed basic web development, but coming to Chapter 3, I found the CSS section a bit of an eye-opener. Not that I know nothing of CSS -- it is something that I have used extensively on my site, but not entirely the optimum way. And what I have just learned, I tried to apply on one of my simple web applications.

Did I find something to blog on?

You betcha!

I am one who always practiced organization, and I just find that the stylesheet file that was created in the process is 'mixing' with the code files. I just didn't like that. So in the middle of streamlining the CSS codes, have done some pages already, I moved the stylesheet to the \App_Code folder. There was no objection in the IDE...

So, I completed migrating all the inline and embedded styles into the Stylesheet file, so they are all in one common place, and this gave me a chance to remove all redundant and duplicate styles. Wow! Just think of the junk I created... And that is just in the simple web apps...

Anyway, having done everything, I now proceeded to test if what I did works.

Surprise, surprise!

In IE, it did not work. I am using IE10, running in Windows 7 Enterprise. The fonts and colors are all using the default values.

I tried it in Maxthon, in most likelihood, the closest browser to IE. The same behaviour was observed.

I now tried Firefox, and the styles came forth, shining through!

But since the majority of browsers used in our company is IE, I have a problem...

I tried defining the font in the individual rule sets, since the * { font: ...} rule doesn't seem to work at all.

No change.

I put the font definition in the body { ... } rule, and still, no effect.

At this point, I now thought of doing one thing: search the web. Search the web for similar issues and of course, the possible solution to my problem.

Found one article that mentioned the problem to be related to some server issues, and also on the folder/directory that keeps the stylesheet file. Spaces must be replaced with underscore (_).

Well, mine is having an underscore (\App_Code\), so I ruled it out.

I stopped for a while, and tried to think some more...

Then, out of a wild guess, I thought of moving the stylesheet file out of \App_Code\ folder, and back into the main folder.

Did that work?

Yes, it did!

So it wasn't the folder having spaces, and it wasn't the server behaving erratically, but simply, and I confess I don't know why (I don't understand it), the problem was simply due to where the stylesheet file was located.

So a few more code corrections, putting back all those definitions [ * { font: ... } ], and making sure all sections work, I published my modified web apps.

Hopefully it is much faster now.

Till then!
Enhanced by Zemanta