Install my software on another PC with local DB - not working - vb.net

I have publish my software but when I install it on another PC I recieve the message Sql Network interfaces error 50 or 52 ..
When the database was localdb, I didn't have to install the sql server.
Can anyone explain it to me, please.
My db code looks like this:
configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="Real_Programi.My.MySettings.REALDATAConnectionString"
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\REALDATA.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>

Related

How to host the core project with IIS using mdf file

I have tried to host the core project with mdf file in the IIS server. The below webconfig file works fine in the localhost. But when I publish it to IIS, I got a 500-internal server error.
This is the webconfig:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.entit, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="FileManagerConnection" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|App_Data\FileManager.mdf;Integrated Security=True;Connect Timeout=30" />
</connectionStrings>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824"></requestLimits>
</requestFiltering>
</security>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" arguments="%LAUNCHER_ARGS%">
<environmentVariables />
</aspNetCore>
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
LocalDB is a database instance provided by the Visual studio. In order to make it work in IIS properly, we should start the Visual Studio and change the application pool identity to the specific account that running the Visual studio. But this is not a common way to publish the database, we should add database immigration to the current project so that we publish the database to the remote database server.
Here is an example of database immigration from localdb to a remote SQL server.
How to transfer ASP.NET MVC Database from LocalDb to SQL Server?
Feel free to let me know if there is anything I can help with.
The .mdf files are SQL Server database files. No other application can understand, read, or update those files. So, I have installed the SQL server in my machine and then host the core project in IIS.

IIS Application is unable to connect to SQL Server database but works when testing in Visual Studio

My web app is supposed to be a drop down menu that connects to my SQL Server database and gives me list of choices. When running it through Visual Studio, everything works fine. A list of choices is shown after clicking on the drop down menu.
However after publishing it to IIS, the drop down menu appears blank. I've tried adding NT AUTHORITY\NETWORK SERVICEuser in the SQL Server database. And setting the application pool identity to NETWORK SERVICE as well but it still doesn't work. I also made sure that the IIS and the application pool has proper access to the SQL database, and pretty much whatever solution I can google but nothing seems to work.
This is the connection string in my web.config, I've changed the actual names of the databases and password for security sake.
<connectionStrings>
<!--<add name="Database1"
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=Catalog1;Integrated Security=True;Pooling=False"
providerName="System.Data.SqlClient" />-->
<!--<add name="Database1"
connectionString="Data Source=MyBD;Initial Catalog=Catalog1;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=P#ssw0rd;"
providerName="System.Data.SqlClient" />
<add name="Database2"
connectionString="Data Source=MyBD;Initial Catalog=Catalog2;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=P#ssw0rd;"
providerName="System.Data.SqlClient" />
<add name="Database3"
connectionString="Data Source=MyBD;Initial Catalog=Catalog3;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=P#ssw0rd;"
providerName="System.Data.SqlClient" />-->
<add name="Database1"
connectionString="Data Source=MyBD;Initial Catalog=Catalog1;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=P#ssw0rd;"
providerName="System.Data.SqlClient" />
<add name="Database2"
connectionString="Data Source=MyBD;Initial Catalog=Catalog2;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=P#ssw0rd;"
providerName="System.Data.SqlClient" />
<add name="Database3"
connectionString="Data Source=MyBD;Initial Catalog=Catalog3;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=P#ssw0rd;"
providerName="System.Data.SqlClient" />
</connectionStrings>
I'm not sure if it's a problem with my connection strings, or that I'm not publishing the website properly.

Can't connect to SQL in web.config

This is my web.config SQL:
<connectionStrings>
<add
name="UsersDB"
connectionString="Server=MYSQL5008.myWindowsHosting.com;Database=db_9b443f_users;Uid=9b443f_users;Pwd=YOUR_DB_PASSWORD;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<membership defaultProvider="SqlProvider"
userIsOnlineTimeWindow="15">
<providers>
<clear />
<add
name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="UsersDB"
applicationName="MyApplication"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="true"
passwordFormat="Hashed" />
</providers>
</membership>
<compilation debug="true" targetFramework="4.0" />
</system.web>
Can you tell me what's wrong here please? Thanks!!
And don't mind the 'YOUR_DB_PASSWORD', I just changed it so I can show you the code..
Given that your appear to be connecting to an external server
MYSQL5008.myWindowsHosting.com
ensure that there is an appropriate firewall rule in place to allow the SQL server connection through. The default port is 1433.
There are quite a few other configuration items to check in general, but since this appears to be a hosted SQL solution the firewall is by far the most likely.
UPDATE
As noted by #Steve, is this a SQL Server or MySQL database? If MySQL, you need to change the provider name in your configuration. See
http://dev.mysql.com/doc/connector-net/en/connector-net-tutorials-asp-roles.html
for details.

Private NuGet Server: Request Entity Too Large

We have a internal NuGet server (ASP.net app using the NuGet.Server package) and we want to use it with Octopus to deploy packages. So the first thing you hit is that the packages are too large.
When you push a package larger than around 7 Meg you get:
Failed to process request. 'Request Entity Too Large'.
The remote server returned an error: (413) Request Entity Too Large..
Based on the documentation on Octopus, I updated the web.config file to have the changes.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/>
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah"/>
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah"/>
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
</httpModules>
<httpRuntime maxRequestLength="419430400" executionTimeout="3600"/>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler"/>
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler"/>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler"/>
</modules>
<staticContent>
<mimeMap fileExtension=".nupkg" mimeType="application/zip"/>
</staticContent>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="419430400"/>
</requestFiltering>
</security>
</system.webServer>
<elmah>
<security allowRemoteAccess="false"/>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data"/>
</elmah>
<location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode"/>
</handlers>
</system.webServer>
</location>
<appSettings>
<add key="apiKey" value="KeyHere"/>
<add key="packagesPath" value=""/>
</appSettings>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
</configuration>
That does not work. Other posts talk about running something like (IIS7):
appcmd.exe set config -section:system.webServer/serverRuntime /uploadReadAheadSize:"419430400" /commit:apphost
or (IIS6):
cscript adsutil.vbs set w3svc/1/uploadreadaheadsize 419430400
I tried both to no avail. Neither command returned an error, so I assume that the value '419430400' is correct for all of the calls (bytes vs. some other unit of size).
Anyone have any idea what I am missing?
I ended up just copying the package to a share on the web server, but I would really like the push command to work.
Not exactly answering the OP's question, but related to the topic, I was getting the (413) Request Entity Too Large error while using NuGet push to push to a local SymbolSource server - turned out I was submitting to a slightly incorrect URL, once I corrected the command to point to the base /NuGet/ URL, it ran just fine.
No idea why an incorrect URL results in the 413 error, but there you go. Hope this helps someone.
EDIT: based on comments below, you may have more luck just referencing the base http://www.myserver.com/ URL rather than including the /NuGet as well. Worth playing around a bit.
I know this is an old question, but today I was faced with the same error. It's worth noticing that I'm using TeamCity package building and publishing. Anyway, when I try to Publish my huge package (about 200 MB) I was blocked with this. The solution was simple:
Instead of publishing to http://mynugetserver/api/v2/, use: http://mynugetserver/
You'll have to set these guys to higher values:
system.web - httpRuntime - maxRequestLength to, say, 1048576
system.webserver - security - requestFiltering - requestLimits -
maxAllowedContentLength to, say 1073741824
Both values are in a different unit so the second one should be larger than the first.
Also, have a look at www.myget.org which I found great when working with Octopus Deploy.
Check your serverRuntime configuration.
The maxRequestEntityAllowed and uploadReadAheadSize attributes respectively configure limits for the maximum number of bytes allowed in the entity body of a request and the number of bytes a Web server will read into a buffer and pass to an ISAPI extension.
More details: http://www.iis.net/configreference/system.webserver/serverruntime
My guess is that you are using SSL and setting uploadReadAheadSize will solve the issue. Because during client renegotiation process,the request entity body must be preloaded using SSL preload. SSL preload will use the value of the uploadReadAheadSize property, which is used for ISAPI extensions.
Here are the defaults
<location path="Default Web Site">
<system.webServer>
<serverRuntime enabled="true"
uploadReadAheadSize="49152"
maxRequestEntityAllowed="4294967295" />
</system.webServer>
</location>
Based on #Keith and #Nubigetter's answers, I did some further research, because the behavior seemed really weird to me.
The answer is actually in the documentation for Nuget.Server (if you look very carefully), it's just not very obvious:
use http://mynugetserver/nuget for list/restore
use http://mynugetserver/ for push
I've raised this with the Nuget team here https://github.com/NuGet/NuGetGallery/issues/2903 because I regard this behavior as 'presenting opportunity for improvement'.
This is due to nginx limitations, the nuget server in Linux system use nginx as proxy and config file under:
/etc/nginx/conf.d/nuget.conf
server_name localhost;
root /var/www/public/;
client_max_body_size 200M;
change client_max_body_size 200M is working for me.
I had the same issue:
[Step 1/2] Publishing package to feed at http://localhost/OctopusDeploy/nuget/packages...
[Step 1/2] Failed to push to package feed at 'http://localhost/OctopusDeploy/nuget/packages/'.
[Step 1/2] (The server responded with: [413] Request Entity Too Large)
[Step 1/2] Process exited with code 1
but the Octopus Deploy service had stopped!
What worked for me was in this article:
http://blogs.blackmarble.co.uk/blogs/rfennell/post/2012/10/31/403-and-413-errors-when-publishing-to-a-local-Nuget-Server.aspx
"Important: This second error was a red herring, you don't need the /nuget on the end of the URL"

XmlMassUpdate - How to delete a node

We would like to use msbuild to clear the connectionStrings section from a web.config file.
What is the easiest way to do that?
We have previously used XmlMassUpdate to replace values (see also this question: XmlMassUpdate - Replace Value Node), but have not found a way to remove it entirely.
More details:
We would like to change the section in web.config from
<connectionStrings>
<add name="connectionString1" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=Db1;Integrated Security=True" />
</connectionStrings>
to
<connectionStrings>
</connectionStrings>
Try this in your substitutions file
<connectionStrings xmu:action="remove" />
This should completeley remove the <connectionStrings> tag.
Give this a shot:
<connectionStrings>
<add xmu:key="name" key="connectionString1" xmu:action="remove" />
</connectionStrings>
I tried something similar to the following and it seemed to work:
<connectionStrings>
<add xmu:key="name" name="connectionString1" xmu:action="remove" />
</connectionStrings>
(note name= instead of key=)