Deploying Microsoft ASP.NET application - c#

I am trying to deploy an Microsoft ASP.NET application over to a hosting provider. I don't think I am able to configure the IIS server or anything like that.I have managed to upload my files to the server through FTP but I am facing the error:
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections."
I am able to access the databases of the domain but I am not sure what configurations to use especially for my web.config. I am using an mdf file
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="DBConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Details.mdf;Integrated Security=True;User Instance=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0">
</compilation>
<authentication mode="Forms">
<forms timeout="50"/>
</authentication>
<sessionState cookieless="true" regenerateExpiredSessionId="true" mode="InProc" timeout="60" />
<httpRuntime executionTimeout="180" requestValidationMode="2.0" requestPathInvalidCharacters="" maxRequestLength="1048576" />
</system.web>
</configuration>

It looks like your application is using SqlExpress to work with a local (to your project) database. Two things to look for - first, did the MDF absolutely make it to your deployed location? Sometimes things in App_Data are left behind during a publish. The other thing to check is whether the hosting provider to which you've deployed supports SQL Express and that the Data Source in your connection string is the proper way to utilize it on that platform.

Related

Runtime Error after deploy asp.net webforms app in Microsoft Azure App service

I am trying to deploy in Azure WebApp service an ASP.NET Weforms.
The app runs fine locally, without any problem.
After build ends I got the error below error in web browser after i go to myapp.azurewebsites.net i
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
Here is source of Web.config file
<?xml version="1.0"?>
<configuration>
<configSections/>
<connectionStrings>
<add name="constr" providerName="System.Data.SqlClient" connectionString="server=telendar.database.windows.net; database=TrackerDB;uid=telendar;password=*****;"/>
</connectionStrings>
<location path="Admin">
<system.web>
<customErrors mode="On"/>
<authorization>
<allow roles="Administrator"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<system.web>
<compilation debug="true" targetFramework="4.5.1"/>
<sessionState timeout="60"/>
<authentication mode="Forms">
<forms defaultUrl="~/Default.aspx" loginUrl="~/AuthUser.aspx" slidingExpiration="true" timeout="60"/>
</authentication>
<authorization/>
<pages controlRenderingCompatibilityVersion="4.0" validateRequest="true">
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
</controls>
</pages>
</system.web>
</configuration>
You misunderstand the error message, it's telling you that your code crashed an unhandled exception and it's not allowed to show it ,it suggest you modifying the web.config to enable the details of the specific error message to be viewable on remote machines.
So what you need to do is recreate the error while you browse it on the server and then solve the problem.
However my suggestion is you could try to change your FrameWork maybe this will work for you.
If you still have other questions, please let me know.

Getting error while hosting WCF service when add <trust level="Full" />

I am trying to host WCF service in "hostgator". I want to set Trust level because I am getting security permission error.
When I set Trust Level in web.config, I am getting an error.
web.config:
<location allowOverride="true">
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<identity impersonate="false" />
<authentication mode="None" />
<httpRuntime maxUrlLength="1024" relaxedUrlToFileSystemMapping="true"/>
<customErrors mode="Off"></customErrors>
<securityPolicy>
<trustLevel name="Full" policyFile="internal"/>
</securityPolicy>
</system.web>
</location>
Error:
An application error occurred on the server. The current custom error
settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could,
however, be viewed by browsers running on the local server machine.
Can anybody suggest a way to solve this?
enter image description here
Per HostGator FAQ you must run in partial trust using their shared hosting:
No. The applications must be published in Medium Trust in order to run
on the Windows Shared Server.
You're not going to be able to use the SDK in a medium trust environment from what I've read. As Dynamics CRM 2016 expands its support for its REST API that may become an option for you.

Configuration error: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level

I have developed a web application using c# and asp.net but when I am trying to publish and put it into the server using ftp then I am getting this following error:
Configuration Error
Description: An error occurred during the processing of a configuration
file required to service this request. Please review the specific error
details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This error
can be caused by a virtual directory not being configured as an application
in IIS.
Source File: \\fs8-n02\stor10wc2dfw1\555713\570520\www.gxxxxjjsxx.ssd\web\content\2way\armb
\web.config Line: 9
Here if I check on my Line 9 of the web config file then I get this:
<authentication mode="Forms">
And here is my complete web config file code:
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<authentication mode="Forms">
<forms loginUrl="Login.aspx" timeout="2880"/>
</authentication>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages validateRequest="false">
<controls>
<add tagPrefix="ajaxtoolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolKit" />
</controls>
</pages>
<globalization culture="en-GB"/>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
I have checked whether I have multiple web config files but I could not find something like that. And also I have used this published folder into my IIS and I can browse the site from my localhost using IIS but still when ever I am trying to browse using the link:
I am getting the same error. Please help me on this. Thanks.
Here is my solution to the problem: Actually the path was not configured properly into the IIS as a virtual directory. So, that I had to create a proper virtual directory and then only I am able to access the site.

Connecting to remote server

I have a windows server on domainindia.org. I have created one user for mysql and I am trying to connect to MySQL using the following connection string in c#.
Driver={MySQL ODBC 3.51 Driver};Server=IPaddress;Database=db1;User=user;Password=password; Option=3;
I am unable to connect. Can someone tell me what may be the problem in this connection string?
The same connection string is working in my local.
I tried to grant permission for that but does not allows me to execute the query.
Can any one tell me how can I connect to my server?
Here is my web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="dbConnection" connectionString= "Driver={MySQL ODBC 3.51 Driver};Server=IPadress;Database=db1;User=Myuser;Password=myPassword;Option=3;"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
</configuration>

Validation of viewstate MAC failed.Application hosted by a Web Farm, ensure <machineKey> configuration [duplicate]

This question already has answers here:
Asp.net Validation of viewstate MAC failed
(17 answers)
Closed 9 years ago.
net 4.0 frame work,
I had made many website in this frame work but never get such error
"Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."
I think so this error is caused because of use of cookies as only in this website i had made use of cookies.
Another one thing i used to get this error very rarely almost 2twice a week
I had read many solutions for this but very rarer for 4.0
solution readed such as putting
<machineKey validationKey="6628ECBFB40F6F852AB543C23C0B83C1679C5AAE35AD72FACF5B9F4FDB70AA1F648A1D5877CE1F9D69F08BAD919BFBAC0976D9119B8F32CFB80814E4E943F8EE" decryptionKey="42F45B378301126EB4CCBA16995304263754EF116E08A81003A936CC04B7537F" validation="SHA1" decryption="AES" />
in web config
OR Adding
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />
in webconfig
But where should i add in my above web config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="Conn" connectionString="Data Source=abc; Initial Catalog=alfadesi_trikon;User ID=abc;Password=abc" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<globalization culture="en-AU" uiCulture="en-AU" />
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Windows"/>
<customErrors mode="Off"></customErrors>
</system.web>
</configuration>
you can add your machine key in system.web element.
for e.g.
<system.web>
<machineKey validationKey="1234567890123456789012345678901234567890AAAAAAAAAA"
decryptionKey="123456789012345678901234567890123456789012345678"
validation="SHA1" decryption="Auto" />
</system.web>
If you don't want to put a machinekey in the web.config for each application, you need to put it in machine level web.config for each .Net Framework version.

Categories