Getting the error "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine" only on one site - oledb

I have seen many posts here and elsewhere regarding this error. In every case the solution is to either uninstall any 32-bit office components, or to change the target platform of the .NET project that's trying to access the driver to x86 instead of Any CPU. Neither of those solutions worked for me.
Here are the details. I have two ASP.NET sites on the same server running Windows Server 2008. One is a production site and the other is a staging site. I am trying to generate an Excel file via OLEDB. The production site produces the file with no problem. The staging site throws this error. Both sites are identical except for the host headers and the SQL Server database they connect to. The target framework for both is 4.5 and the App Pool is set to use 4.0.
Has anyone else come had this problem?

Turned out to be an IIS7 configuration problem. Each site had its own App Pool. On the advanced settings dialog, under (General), there is an attribute named Enable 32-Bit Applications. This attribute was set to True on the stage site. Changing it to False resolved the issue.

Related

Windows Server 2019: IIS 10: HTTP Error 403.14 - Forbidden: The Web server is configured to not list the contents of this directory

All,
I am migrating a working .Net Framework Website from IIS 8.5 on a Microsoft Windows Server 2012 to IIS 10 on a Microsoft Windows Server 2019.
The new web site is showing the error
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
As far as I can see the website on the new server is configured the same as on the existing.
Neither have directory Browsing enabled nor a default file set as is recommended by most of the posts which exist discussing this error.
I have run the following which is also recommended.
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
The problem still exists.
I came across a post saying there might be an issue if paths referenced in the web.config are not correct but they look fine.
Has anyone got any insight into what else might cause this issue?
Are there any differences between IIS 8.5 and IIS 10 or between windows servers 2012 and 2019 which might cause this issue?
Thanks
This problem occurs because the website doesn't have the Directory Browsing feature enabled. Also, the default document isn't configured. To resolve this problem, use one of the following methods:
Method 1: Enable the Directory Browsing feature in IIS
To resolve this problem, follow these steps:
Start IIS Manager. To do it, select Start, select Run, type inetmgr.exe, and then select OK.
In IIS Manager, expand server name, expand Web sites, and then select the website that you want to change.
In the Features view, double-click Directory Browsing.
In the Actions pane, select Enable.
Method 2: Add a default document
To resolve this problem, follow these steps:
Start IIS Manager. To do it, select Start, select Run, type inetmgr.exe, and then select OK.
In IIS Manager, expand server name, expand Web sites, and then select the website that you want to change.
In the Features view, double-click Default Document.
In the Actions pane, select Enable.
In the File Name box, type the name of the default document, and then select OK.
More information you can refer to this link: HTTP Error 403.14 - Forbidden when you open an IIS webpage.
All those clowns glibly posting that "HTTP Error 403.14 - Forbidden: The Web server is configured to not list the contents of this directory" can be fixed by configuring the web site by either enabling the Directory Browsing feature or adding a default document are really not understanding what they are talking about. Anyone can copy a solution from one post and paste to another.
I'm not going to pretend I know what I am talking about but I have fixed my issue and will share what I did here to see in the hope it helps others.
I created a project (of the same type as the application I was trying to deploy) using my IDE (MSVS) in the same .Net version of the application I was trying to deploy. In this case it was creation of an MVC project in .Net Framework 4.5.
I did nothing to it. All I wanted was a skeleton.
I replaced all the files in the home directory of the web site I had an issue with, with the files of this skeleton project.
I attempted to browse to the web site and it worked successfully. Note the directory browsing was not enabled nor was a default directory set.
This proved to me that those settings were irrelevant.
Having googled around, some sites point to paths in config files causing an issue if they do not exist, eg a logging path to d:\logs where that directory was missing. It didn't fix my issue but there's no harm checking.
I stumbled across a post which talked about the roles and features enabled on the server. In Web Server (IIS)/Web Server/Application Development they had selected "Application Initialisation" and "ASP".
The Windows Sever 2012 server I was moving the application from, where it work without a hitch, did not have those selected so had not selected them on the Windows Server 2019 I was moving them to when I set that server up.
It made no sense that this would be the solution but having tried everything else I activated those two options.
Stone me if the issue was resolved.
As a check I removed those two options and the problem came back and when I reselected them it went away again.
This struck me as pretty conclusive only having thought I'd found the cause of the problem I built the website from scratch and the problem came back again.
It took a number of iterations but eventually I got there, more by luck than judgement and whatever the cause was it was due to an issue in the application which wasn't being logged in event viewer so focus on permissions to files being written to: not only that the app pool account is set up on the directories it needs access to but also that it has modify or even full control.
All those muppets robotically posting advice on configuring the web site by either enabling the Directory Browsing feature or adding a default document will no doubt copy this and paste it into their posts to claim the credit but c'est la vie.
I hope this post is of use to someone, apart from those muppets.

How to change Machine Key generated by Visual Studio ASP.NET MVC Project?

I'm working on an ASP.NET MVC Web App with Office 365 authentication. The web app runs perfectly on my computer, but when I transfer and run the project on other computers and on Azure, it gave me a Cryptographic Operation Error. After some research, I concluded that the Machine Keys are the ones causing the problem.
I have found the MachineKey for the Azure Web App Service, but when I put it in my local Web.Config, it still looks for my computer's original Machine Key. The same happens when I set it to auto-generate, both my computer and Azure throw the same error.
I need a way to reset the Machine Key my application is looking for. For example, if I set the Machine Key in Web.config to "KEY_EXAMPLE_HERE", my application will start to use that key. That way, I can set up the same Machine Key in all servers I need to run my application.
I don't know if the application looks for the key it generated when I created the Visual Studio project, but I need a way to change it.
Any help will be appreciated, thanks!

404 error on azure for Asp.Net Web Api Project

I have deployed exact same solution on two servers, one is my own server in my basement and the other one is Microsoft Azure. The project is developed using Asp.Net Web Api 2.
On my own windows server running IIS 8.5 it totally works. For test, you can simply browse this link in your browser and see the error message {"Message":"The requested resource does not support http method 'GET'."} which shows the API has been hit.1
But exact same project on my Azure domain here, you just get a message saying
The resource you are looking for has been removed, had its name
changed, or is temporarily unavailable.
Everything about these two deployments is the same (to the best of my knowledge) and I was wondering if there is any further steps necessary on Web Api app deployment in MS Azure which I am missing.
I finally found the answer to this issue. If there are multiple apps deployed as one single website so each app is located in its own subfolder, you have to go to the configuration section of your web app on Azure and create virtual directories for each of those sub folders.
Ah, my problem was probably a common one. I was using
rootconfig = System.Web.Configuration.WebconfigurationManager.OpenWebConfiguration(null);
and that was returning the root web because the parameter was null.
When I ran it local that worked fine, but after I deployed the root Config was NOT what I wanted and my code was failing.
Switched to direct access via
stringVal = WebconfigurationManager.AppSettings["Foobar"].ToString();
Nice. Plus less overhead.

What do I need to do to get MVC to work on IIS7? Does not show page, just shows directory

I've just file system deployed an intranet site to one of our internal servers. The site is configured with it's own application pool w/.net 4. The site is configured to allow anonymous access. The NetworkServices account has read access to the directory/s. For trouble shooting purposes I have directory listing enabled.
When I hit the site I get the directory listing, why does the home/index page not come up as expected? Other servers that I have deployed to have just worked. I can not seem to find a difference here.
Also I have the site configured to come up as http: //myip:8081/
I've already run aspnet_regiis -I and checked to make sure the pool was the correct version.
I rolled back my .Net version from 4.5.1 to 4 and reinstalled all the nugget packages.
I have copied local all the DLLs just to be sure.
The original project was targeted to .Net 4.5 and I had down-converted to 4. I thought I had changed all references and configuration items but I must have missed something.
I created a new project targeting .Net 4 and copied my code files into the new project.
Compiled and deployed and all worked correctly.
Not sure what item in the web.config wasn't changed (or maybe something else in the project) but this worked and was fairly quick.

W2K8 server running IIS7 VS Express Web Deployment

(EDIT) - I decided to make this page more like instructions since i have figured this out.
Deploy my VS Express 2013 Web Application to an MS Server on my LAN running:
Windows Server 2008 Standard
IIS 7.0
MS SQL Express
This is some information to help anyone with a similar situation.
I can access the Web Application locally (from VS Express) when I click Debug - Start Debugging. ALSO - At this point it is connected to the MS SQL Express Server on my LAN and not a local database.
Time to publish the Web Application to my IIS 7 Server!!!
NOTE - The method below WORKS FOR ME. There might be better ways to do it but I found any info on this exact setup very limited.
VS Express 2013 Web Deploy pre-reqs:
(on IIS 7 Server)
-Web Deploy is installed, http://www.iis.net/downloads/microsoft/web-deploy
-Set Up Security on Web Deploy, this site helps:
http://www.iis.net/learn/install/installing-publishing-technologies/installing-and-configuring-web-deploy
In Project:
Right Click your project name, choose PUBLISH...
PROFILE - Name or import your profile
CONNECTION
-Server: LAN address of your IIS server
-Site Name: Name of Site on IIS
-User/Pass: (Credentials you set up earlier in Prerequisites)
-Destination URL: (I leave blank for now)
SETTINGS - Click the arrow below FILE PUBLISH OPTIONS and check the 'Exclude App Data' setting (this is assuming you are running MS SQL on the IIS Server).
Select your Database string, it should be in the drop down list)
PREVIEW - Web Deploy will give you errors when you try to PREVIEW, resolve these errors using MS Websties, Stack Overflow, etc. **WHEN YOU GET THIS ERROR: "#ERROR_FRAMEWORK_VERSIONS_DO_NOT_MATCH" (full Error message below), your Web Deployment is ready
PUBLISH the web deployment, it wont work, thats okay. It creates a publish profile
Right-click the project and choose PUBLISH again, this time use under the CONNECTION tab choose WEB DEPLOYMENT PACKAGE, take note of your folder location (Step 8). All the database/file settings should be the same (doublecheck if you like), PUBLISH the Web Deployment package
Log onto your IIS Administration (on the Server), right click the NAME of the Server (top level) and choose DEPLOY - IMPORT SITE. Navigate to the folder where you saved the package in step 7. (or transfer it with a USB Stick, etc)
IMPORTANT - When importing the profile, at the second screen, UNCHECK the boxes related to .NET 32-Bit etc. (there are two of them)
Leave everything else on defaults and import the site (successfully?).
At this point when I browse the site from IIS I get a 403 Forbidden Error.
I fixed this using code from comment below:
After that my Web App was from the IIS Server. I'm continuing with MVC tutorials found here:
http://www.asp.net/mvc/tutorials/mvc-5
I'm hoping once I understand enough about MVC and EF6 I can connect the Web App to MySQL rather than MS SQL and still build Code First Applications. If anyone has info on that please post it in the comments.
If this post helped you please Vote up top, I'm new to the STACK.
**Full Error Message from post above:
Web deployment task failed. (The versions of the .NET Framework Configuration Provider (rootWebConfig32) are different on the source (4.0) and destination (2.0). Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FRAMEWORK_VERSIONS_DO_NOT_MATCH.)
I think your issue might be permissions. What is your authentication set to? In debug mode, you're typically working as yourself, whereas if you deploy, you are setup as a different user, most likely anonymous. With that in mind, you should be able to correct your problem.
Good luck!
It was a combination of things. I finally got it working.
I created a Deployment package following instructions found on MS site and others.
Before Publishing my deployment package, I ran a "Preview" (PREVIEW section of the wizard). This was bringing up various errors related to Security and other issues I fixed using MS support sites.
WHAT I FOUND ON MY OWN - (Its fairly simple), after you create the Deployment package without issue, go to IIS on the Server side, click the Server Name in IIS (top level) and choose Deploy - Import Package. In the second or thu=ird step there is a screen where you select items to be imoported (mine had everything checked). I UNCHECKED the two related to .NET Config files and imported it. Voila, it worked.
It still wasn't letting me view the site. I had to add this line to the web.config file and it fixed everything.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
If anyone wants a mored etailed description of what I did let me know and I will try and redo my process/tutorial with more exact instructions.
to get the same publish behaviors with direct publish from VS, you can uncheck following box : properties\Package/PublishWeb\include IIS express settings as configured in ISS express

Resources