How to publish web application using Visual Studio 2017?

ram
ram used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Co-Founder and Chief Architect
Top Expert 2016
Commented:
It's pretty straightforward:

Right click and choose 'Publish'
publish1.png
Choose FTP
publish2.png
Enter in the details
publish3.png
Choose any settings that you want
publish4.png

I assume your FTP site is set up, but that will be required to be functional obviously.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

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

Author

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:

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?
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

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

Author

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:

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 PatelChief Technology Ninja
Distinguished Expert 2018

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

Author

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:

Capture.png
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

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

Author

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:

  <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 PatelChief Technology Ninja
Distinguished Expert 2018

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

Author

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?
ram

Author

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

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

Author

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 Technology Ninja
Distinguished Expert 2018

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

Author

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.

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

Author

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:

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

Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

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

Author

Commented:
Yes, but how do I change the connection string though? Does |DataDirectory| automatically point to the App_Data sub folder?
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

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

ram

Author

Commented:
Thank you for all the help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial