I have a website which is working fine locally but not on remote server. Its a MVC4 and Elmah is configured for SQL Server.
I can throw a simple error and see it on elmah locally in my iis (same code).
Config are exactly same, SQL Server ... everything.
On remote server when I test the elmah with http://example.com/elmah.axd/test
it logs the error correctly.
Any other error in code is not showing up on elmah.
I checked the Application Pool and its integrated.
I appreciate any help or idea.
You need to enable Elmah for remote access by adding the following configuration setting to the section in your web.config file. The default setting for this value is false, which only allows localhost, hence why it is working on your local machine from within Visual Studio.
<elmah>
<security allowRemoteAccess="true"/>
</elmah>
Make sure you HttpHandler is defined in the webServer section in your web.config file.
<system.webServer>
<httpHandlers>
<add name="elmah" verb="GET" path="elmah.axd" type=type="Elmah.ErrorLogPageFactory, Elmah"/>
</httpHandlers>
</system.webServer>
Related
We have an application which we are attempting to revive that was written in classic ASP in 2010. So far, I've done the following:
I created a Microsoft Server 2016 instance on Amazon EC2
I installed IIS Server
I created the website inside the IIS Manager, added/linked the files, and successfully ran the application on http://localhost
I installed SQL Server 2017 and imported the DB Backup (and successfully created the database)
I created a SQL Server user and tested that I can access the DB using the created database user
I enabled SQL Server Login Authentication and Windows Authentication Mode
I added the connection to IIS Manager.
I confirmed that web.config.xml has the proper information.
Im getting the following error:
2018-01-21 01:36:16 ::1 POST /intranet/process.asp |178|80004005|[Microsoft][ODBC_SQL_Server_Driver][DBNETLIB]SQL_Server_does_not_exist_or_access_denied. 80 - ::1
I noticed in the code theres a file that has a Session config for a database connection that doesnt look the same.
Im not sure what to do at this point. We need to figure out how to connect this database to the application
Heres my web.config.xml in the root:
<configuration>
<appSettings />
<connectionStrings>
<add connectionString="Server=server\SQLEXPRESS;Database=dbname;User ID=dbuser;Password=dbpass" name="SqlServer" />
</connectionStrings>
</configuration>
Here's my web.config.xml inside the intranet folder which is for an admin area:
<add name="WEB"
connectionString="Server=server\SQLEXPRESS;Database=dbname;User ID=dbuser;Password=dbpass"
providerName="System.Data.SqlClient" />
I noticed a file global.asa that has this:
Sub Session_OnStart
Session("ConnectString") = "Server=adifferentserver;Database=adifferentdatabase;UID=adifferentuser;PWD=adifferentpassword;Driver={SQL Server};"
This is my first time using ASP so you'd have to guide me for what other files you need.
The global.asa file in Classic ASP acts as an initialisation script it is commonplace to set long-running variables such as Application and Session variables there.
If this file contains a connection string variable then that is the value to change to your migrated database. At the moment process.asp is using Session("ConnectString") and ADODB is trying to locate adifferentserver using the SQL Server provider and failing. Once you correct the connection string using the required provider and server, database combination the page should work.
The other two values come from the web.config which was brought in with IIS 7.0 and above, it's designed for Microsoft .Net and Classic ASP does not know about connection strings configured inside it. The likelihood is there is another web application that uses ASP.Net that was making use of those connection strings.
So we have developed an MVC application with EF database first and are trying to deploy the solution to Production environment. however the database server is on a different server and hence we would have to provide a conenction string pointing to the DB server. We tried couple of methods but weren't successful.
Whats the approach for deployments for EF DB first?
Have you tried this code?
Configuration connectionConfiguration = WebConfigurationManager.OpenWebConfiguration("~");
connectionConfiguration.ConnectionStrings.ConnectionStrings["test"].ConnectionString = txtConnectionString.Text;
connectionConfiguration.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("connectionStrings");
It will rewrite your web.config with new values
When deploying to a production environment, an application is typically compiled in Release mode. In this mode you can use Web.Release.config to specify the variables that should be different in production.
Say your connection string in Web.config is
<add name="MyContext"
connectionString="DevConnectionString"
providerName="System.Data.SqlClient" />
You can add this in Web.Release.config:
<add name="MyContext"
connectionString="ProdConnectionString"
providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes"
xdt:Locator="Match(name)" />
When deploying to production the connection string will automatically change to "ProdConnectionString".
For more information on Web.config transforms see How to: Transform Web.config When Deploying a Web Application Project
I recently upgraded my PC from Windows 7 to Windows 8.1 and am now having problems resetting up my local DNN5 environment.
I pulled my DNN5 instance down from a remote git repo, and just finished importing all of the tables/data/stored procedures from the production DB to a local instance.
I have updated the connection strings in the web.config to reflect my new database, but still, no matter what I do, I am getting redirected to http://localhost/DNN5/Install/UnderConstruction.htm.
What am I missing?
for completeness, here are my connection strings and a screencap of my db:
<connectionStrings>
<add name="SiteSqlServer" connectionString="Data Source=KMCNUTT-7\DWYATTMSSQL;Initial Catalog=DNN5;User ID=sa;Password=******"
providerName="System.Data.SqlClient" />
<add name="DNN5ConnectionString" connectionString="Data Source=KMCNUTT-7\DWYATTMSSQL;Initial Catalog=DNN5;User ID=sa;Password=******"
providerName="System.Data.SqlClient" />
</connectionStrings>
This almost always happens when you are unable to connect to the database from DNN.
Navigate to
http://localhost/DNN5/Install/install.aspx
and see if it throws a connection error just to be sure.
Is this a local database? If so try using (local)\InstanceName (I assume your instance name is DWYATTMSSQL) so (local)\DWYATTMSSQL
Also make sure that you have SQL authentication enabled in SQL server, instead of Windows Authentication only, which is the default for SQL installations.
The article here
:: http://www.microsoft.com/web/post/how-to-publish-a-web-application-using-webmatrix
states that to publish via FTP I must "enter the connection string for the destination database" and gives examples. It is not clear to me if I have to replace the current web.config string, or if I'm adding one. I also don't understand if I have to mark one as a destination database.
Here is what I have thus far. When I visit website it says "under construction". It would be helpful to know how to get it out of that state, and also turn log error on.
<!-- this is the local connection -->
<add name="SiteSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Database.mdf;" providerName="System.Data.SqlClient" />
<!-- this is the destination db -->
<add name="myConnectionStrings" connectionString="Server=205.xxx.xxx.xxx;Database=mydbname;uid=mydbusername;pwd=mydbpasswd;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<!-- Connection String for SQL Server 2005/2008 Express - kept for backwards compatability - legacy modules -->
<add key="SiteSqlServer" value="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Database.mdf;" />
.
.
.
</appSettings>
I work on WebMatrix and found your post so I thought I'd provide some answers:
I'm guessing the reason you see "Under Construction" is some applications include some post-site creation configuration as part of their install. For DotNetNuke specifically it looks like you'll want to visit:
http://localhost:port/Install/InstallWizard.aspx
but you can always click the "Run" button from the ribbon after installing any app to start the configuration process if required.
As for setuping but your site publishing you shouldn't ever need to edit the web.config file. In Bakery application shown in the tutorial uses a file-based database so we're able to easily deploy the database through both Web Deploy and FTP using a simple file copy. DotNetNuke on the otherhand uses a full SQL database so we're not able to publish or download the database via FTP. There is no need to enter any additional connection strings to your app locally but you will be responsible for changing the database connection string in the web.config on the server once FTP publishing is done (as well as other settings that may have changed like the site url).
Since Web Deploy is more than just a file copying protocol if you choose Web Deploy as your publishing method we're able to actually sync your local and remote databases. You'll need to enter the connection string for the remote database server on the Publish Settings dialog along with your other connection information and you can use the Validate button to test those settings.
To view your error log you can go to the Site workspace in WebMatrix and then click on Requests in the left-hand navigation. Make sure the Capture Requests toggle in the ribbon is turned on. Additional options to tweak what is logged are also available in the ribbon.
Hope that helps,
Andrew
I have Elmah running on my MVC 3 site, and have everything working on my local development machine.
However, now that I've moved my site to my production server, Elmah is not working. I am using the same SQL account (and connection string) on my live server as I'm using on my local machine. The EF4 connection (same as Elmah) works just fine.
I don't see anything in the Even Logs or in SQL Profiler. I don't see any errors in the SQL logs either.
Any ideas on what could be happening, or how I could troubleshoot this?
Thanks in advance.
ELMAH is using a HttpModule to log errors. For IIS6, HttpModules are registered under System.Web in the web.config file. However, for IIS7+, HttpModules should be registered under the system.webserver namespace. The embedded development web server will use the IIS6 config.
IIS6:
<system.web>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
</httpModules>
</system.web>
IIS7:
<system.webServer>
<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
</modules>
</system.webServer>