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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dustin SaundersDirector of OperationsCommented:
It's pretty straightforward:

Right click and choose 'Publish'
Choose FTP
Enter in the details
Choose any settings that you want

I assume your FTP site is set up, but that will be required to be functional obviously.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chinmay PatelChief Technical NinjaCommented:
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?

ramAuthor Commented:
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:

I think it's for ASP.Net core, but I'd imagine it's the same, isn't it?
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Chinmay PatelChief Technical NinjaCommented:
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.
ramAuthor Commented:
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:

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 PatelChief Technical NinjaCommented:
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.
ramAuthor Commented:
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:

Chinmay PatelChief Technical NinjaCommented:

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.
ramAuthor Commented:
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:

    <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 PatelChief Technical NinjaCommented:
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.
ramAuthor Commented:
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?
ramAuthor Commented:
Nevermind, it finished but it gave me an error:

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
ramAuthor Commented:
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
Chinmay PatelChief Technical NinjaCommented:
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.
ramAuthor Commented:
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.

Move the access database to a subfolder of www and give anonymous identity modify permissions to the directory.
ramAuthor Commented:
How do I change the path in my connection string to point to the subfolder in the www directory?

The server looks like this:

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

Chinmay PatelChief Technical NinjaCommented:
So they already gave you the solution. Please follow their direction as each host has their own set of policies in place.
ramAuthor Commented:
Yes, but how do I change the connection string though? Does |DataDirectory| automatically point to the App_Data sub folder?
Chinmay PatelChief Technical NinjaCommented:
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

ramAuthor Commented:
Thank you for all the help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.