Avatar of ram
ram
 asked on

How to publish web application using Visual Studio 2017?

I need assistance publishing our web application to our FTP using Visual Studio 2017.

I tried reading the instructions on the Microsoft website on how to do it but I am not well-versed to do it without assistance.

Please help.
ASP.NETFTPC#Microsoft Visual Studio

Avatar of undefined
Last Comment
ram

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dustin Saunders

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Chinmay Patel

Hi ram,

Please let me know which instructions you tried to follow and whether the project you are trying to publish is ASP.Net or ASP.Net core?

Regards,
Chinmay.
ram

ASKER
Dustin, thanks for the step-by-step guide. My solution has 2 projects, the main website and a datalayer (class library). Will both projects be compiled and published?

Chinmay, here are the instructions:

https://docs.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-to-a-web-site

I think it's for ASP.Net core, but I'd imagine it's the same, isn't it?
Chinmay Patel

If your class library is directly referenced in your web site project, it will be automatically deployed.

And yes it should be the same but of late I have heard people facing challenges with ASP.Net core publishing so I thought I'd cross-check.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ram

ASKER
Does having the "Delete all existing files prior to publish" checkbox ticked delete all files in the ftp site path that I assign?

Right now, this is what it looks like when I connect using FileZilla:

Capture.png
I want the database, logs and www folders to go away (I have a backup of these folders anyway). And I think this is what I'll be using
Publish Method:          FTP
Server:                           ftp://www.****.com
Site Path:                       sites/****.com
Destination URL:          http://www.****.com

Is this correct?
Chinmay Patel

Yes. it will delete all the files - or at least try to delete the files in the selected path. I do doubt though if you should target it like this, Ideally you should publish to www folder and leave database and logs as it is.
ram

ASKER
That current structure really isn't needed because my database folder in my web application is named "App_Data" and I'm really not logging anything.

This is what my solution structure looks like:

Capture.png
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Chinmay Patel

Ram,

the folder given to you are by your web host, I strongly recommend against deleting them. The logging folder is maintained by your web host - all the IIS logs and other logs(security, error, diagnostic) will be generated and put in that folder by your host. It is also critical when you try to troulbeshoot a live website. Same goes with the database folder. I suggest you leave it as it is and publish under www folder.

Also whatever your current configuration is, I think you will have to use the database interface provided by your webhost i.e. you will migrate data from your database (instead of uploading the file) to your webhosts's database and change your config so that your app can use the proper database.
ram

ASKER
Oh ok, like I said I am not experienced enough to tackle this without assistance, and I appreciate all the help I can get.

So I change my site path to "sites/****.com/www" and then change my connectionstring to?

This is what my connectionstring looks like right now:

  <connectionStrings>
    <add name="IU_Daily_V1_1_ALLConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\IU_Daily_V1_1_ALL.mdb;"
      providerName="System.Data.OleDb" />

Open in new window

Chinmay Patel

If you are using access then no need to change anything(I suppose) just upload it to your www folder and give it a try.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ram

ASKER
It looks like it stopped. It says "Publishing folder bin/roslyn..." and the status bar is at 50%. Is this similar to the issue that other people are having with ASP.Net core?
ram

ASKER
Nevermind, it finished but it gave me an error:

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
ram

ASKER
Was able to get rid of the 'targetFramework' error by changing the AppPool to the version my application is using.

But now it's giving me another error:

Server Error in '/' Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SecurityException: Request failed.]
   System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +165
   System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100
   System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +284
   System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, RuntimeAssembly asm, SecurityAction action) +70
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +70
   System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +40
   System.Type.GetType(String typeName) +30
   System.CodeDom.Compiler.CompilerInfo.get_IsCodeDomProviderTypeValid() +12
   System.Web.Compilation.CompilationUtil.GetRecompilationHash(CompilationSection ps) +2175
   System.Web.Configuration.CompilationSection.get_RecompilationHash() +96
   System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDateInternal(Int64 cachedHash) +458
   System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate(Int64 cachedHash) +51
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1085.0
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Chinmay Patel

Please check whether your host supports ASP.Net core and if so, whether it is configured correctly. Please ask your host whether they support partial trust or full trust apps or not.
ram

ASKER
Here's what they said:

We've searched for other sites using Server.MapPath in .NET. We believe the medium trust config on this old Windows Platform is going to prevent access to /database.

Suggestion:
Move the access database to a subfolder of www and give anonymous identity modify permissions to the directory.
ram

ASKER
How do I change the path in my connection string to point to the subfolder in the www directory?

The server looks like this:

Capture.PNG
Right now my connection strings look like this:

<add name="UsersConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\users.mdb;"
      providerName="System.Data.OleDb" />

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Chinmay Patel

So they already gave you the solution. Please follow their direction as each host has their own set of policies in place.
ram

ASKER
Yes, but how do I change the connection string though? Does |DataDirectory| automatically point to the App_Data sub folder?
Chinmay Patel

DataDirectory is a substitute string. So once you have configured everything per your host's configuration, all you need to do is
Add this line in your Global.asax Application_Start

AppDomain.CurrentDomain.SetData("DataDirectory", "Complete Folder Path per your Hosts' config");

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ram

ASKER
Thank you for all the help!