Can't Read data From Access Database After Publishing On IIS - c#

I have An ASP.Net web site which reads data from an Access database, It works well, but after publishing it on IIS no data is retrieved.
I'm using the Web config to connect to database
<add name="GisDB" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\AccessDB\Myacdb.mdb;Persist Security Info=False;" providerName="System.Data.OleDb"/>

You may have two specific issues to resolve:
1) IIS cant resolve the path of the Access Database
2) IIS may not be able to instantiate the ACE OLEDB drivers on the server.
A potential solution for 1) is to place the Access database in your /App_Data subfolder off the root of your website. You can specify a connectionstring in the web.config like this
Resolving 2) is trickier, especially if its a remote host. As a start, If using Visual Studio, compile your website binary into x86 mode and see if the problem persists. This could indicate a potential issue with the Access DLLs running on a 64 bit platform.

Almost certainly IIS worker process does not have rights to read files in the d:\AccessDB\ folder. Either grant it rights or move the MDB to an App_Data folder under your website root and change the Web.Config to suit.

Related

Toabsolute() retrieves correct path on development machine but not deployement server

ToAbsolute() method retrieves the path correctly on the development machine but not on deployment. When I use ToAbolute(~/Login.aspx) returns path to specified location correctly. the same on the uploaded website returns just /login.aspx. what else am I missing here?
The difference between the two is your IIS settings for application path. Ensure that they both are set up with the same folder structure and you should be good from there.
In IIS, an Application can be added under a Site at a particular URL... In your local system it appears you've added your application under the /applicationname directory. On the remote server, it appears to be configured for root. Compare the two IIS instances side-by-side and note the differences.

Where are my Application Settings when running on IIS

I have a deployed WCF application running on IIS 7.5 as a site. One of the business dll's of that application (ABC.dll) has an application setting of type "connection-string".
I would like to change that DB connection string but can't find the right place to do it.
The ABC.dll.config in the Bin folder where the application dll's are deployed does not contain the actual connection string the application use at run-time.
How do I find that connection string?
If you have a WCF service running in IIS, you put the configuration in a web.config file in the root folder. This will contain all the settings that apply to your service. It is most likely that the connection string is being used from this file.
It is theoretically possible that if the settings are not in the web.config either, then they might be in the machine.config of the server on which you are hosting your WCF service. It is highly unlikely though that someone would store app-specific connection strings in this file but u never know sometimes.

main considerations while publishing application using SQL server Database

I want to ask about the main considerations we have to put in mind when publishing application using SQLServer database?
I ask this question because I faced a problem when I developed an application using SQL server Database in C# and used it in another machine. The problem is an exception happen in launching the application.
This is the exception message:
<b>"The ConnectionString proberty has not been initialized"</b>. The ConnectionString is in App.config and assing while form loading.
This is the ConnectionString:
<b>"Data Source=.\SQLEXPRESS;Initial Catalog=test;Integrated Security=True;Pooling=False"</b> and it is in this file: appName.exe.config
The application is Desktop application and it's not need for installation just click .exe and it should connect to the existing SQLServer database with the ConncetionString in the appName.exe.config file.
The best way to deploy any type of application will be creating a setup.exe or .msi file.
Since this will ensure the important files which will copy to the target machine. It also provides a well structured file hierarchy along custom action which we can program each and every steps of installation.
It is always good to keep the connection properties in a config file, which helps to change the configuration settings without building the project. The exe will reads data from the config file, so if we changed the values then also it will works fine. While creating the setup project add the configuration settings and deploy or it is also good to have a common setup msi and different config files.
For example the database may be different for servers like DEV,QA,Staging etc. For each sever the msi will be same but the connection string will be different. So there is also a way to create self extracting files which will update the config files . For QA,DEV,Staging etc different self extracting files will be there. by running those files, it is possible to update the server details and authentication details. By providing msi and extracting files, users can install the application very easily

Downloading exe.config file from clickonce with WebClient class problem

I'm downloading from clickonce server new versions of files by my autoupdater. However, any time downloading cycle comes over MyApplication.exe.config file on the server webClient.DownloadFile(remoteFile, localFile) throws a System.Net.WebException with code 500 (internal server error or something like that). At the same time application event log renders few entries from asp.net, like
failed to initialize AppDomain /LM/W3SVC/1/ROOT
Exception: System.Configuration.ConfigurationErrorsException
asp.net process id doesn't have permission to access GAC
aspnet_wp.exe stoped.
But the cycle continues successfully for all other files.
Does it somehow figures that it is config file for a web server, since asp.net is .NET framework itself and "knows" about .config file?
As was already mentioned in the other answer, IIS will not serve .config files. Where my answer is different is the proposed work around: ClickOnce has an option to use .deploy files, where all your file names have a .deploy extension appended to them. This neatly gets around the IIS config transfer problem.
IIS, by default, does not serve up .config files. Do you have access to the IIS configuration on the ClickOnce server, so that you can see if .config is disallowed in the request filtering module?
In IIS 7, it's in Request Filtering in the IIS section. I'll see if I can find where that's configured in IIS 6.

XCOPY to remote server

In order to improve the deployment / build process of my ASP.NET app, I would like to make a .bat that
builds the current solution in release mode
xcopy the files to a remote server
Creating a release build via command line is easy.
But how can I xcopy the files to the remote server?
I think I have to map the remote destination to a network drive (?). However I could not connect to the remote server, although I have enabled file sharing for the folder on the server. Maybe the firewall is blocking the request? Which port should I open? Or is there another solution?
EDIT
Thanks for all the answers so far, but I probably need a step by step guide on how to set up the folder sharing on the server. I shared the folder, I opened up port 445 so that I can connect to the server but still, I cant connect from my local machine to the server in order to map the network path to a system drive.
Since you are deploying a ASP.Net site, I am assuming that you are in a windows environnement (isn't smart ? :)).
SO ! Forget about .bat and go for POWERSHELL !
Anyway, this is not point of your question...
To copy to a remote folder you should have the rights to do so on the Remote computer.
Check if you have the same account on your local computer and on the remote one.
For instance, if you are logged on your local computer in the domain "Work" with the login "Pipo", you must give the rights to this account to write into your special folder on the remote computer.
You can achieve that with a right click on the folder, security options, and then selecting the correct identity.
Here is a step-by-step guide:
http://support.microsoft.com/kb/301281
It might be worth moving the files with XCOPY via a UNC path
\\machine\folder
That will require you to have access to folder from the originating server. Check that the folder has been shared and that the relevant read/write permissions have been granted.
If the server is on your local network, I'd suggest using robocopy instead of xcopy - it has many more useful options and capability to retry on errors. It handles UNC names just fine (as I believe xcopy does too). I think it's available on newer Windows clients - if it's not on your machine Google for it - it's available in various resource kit downloads (I don't know the details of if/when Microsoft started including it in the OS distribution because I've had it in my utility kit for a long, long time now).
If the server isn't local, you can script the command line FTP client to perform the transfer. If you need additional flexibility or security there are many other file transfer options, including WinSCP.
Of course in either case (local or remote server), the server's permissions and your authentication needs to be set up properly for this to have a chance to work.
You can use any UNC path: \\machine\sharedFolder. If you don't want to set up a shared folder, you can reference any of the drives on the machine using a $ sign: \\machine\c$\program files\etc. If your machines are in Active Directory, or if you have a local user on the target machine with the same username AND password Windows will handle the authentication seamlessly.
Have you tried unleash it?
http://www.eworldui.net/unleashit/
It can move files across networks, run pre build bat files, file masking, etc...
I used to use it before on .net 1.1 projects.
I think you want:
XCOPY c:\myproject\build\*.* \\server\\build\ /S /E
All of the above seem to be grand answers - you could look at using an msbuild script and the msbuild community tasks to do all of this - they can zip up your build and ftp it to a remote server.
I've just set this up for one of our sites, took a couple of hours to get my head around it, but it builds the site in release, updates the config files for production, removes unnecessary files and then does the upload.
after looking for so many answers here is the solution
"xcopy D:\\folder\\container \\\\servername\\folder\\container\\ \/E \/H \/Y"

Categories

Resources