Implementing ClickOnce MVC5 page for VSTO add-in - asp.net-mvc

I have a VSTO (Visual Studio 2012) Excel (2013) add-in that I'd like to deploy via an web page (also VS 2012, asp.net MVC5). The ClickOnce deployment package is generated using a TFS build and works fine from a file share, both initially and for updates.
I'm stuck on the web deploy aspect. I've tried both cshtml pages and htm pages and the setup.exe download works fine, but running the setup fails because authentication is somehow triggered and the vsto content is not delivered (logon page is returned). The controller containing the action for the cshtml page (ClickOnceSetup) is decorated with [AllowAnonymous], and I've tried IgnoreRoute options without success.
Does anyone have a working recipe for this approach? None of the posts or examples I've found have put all these pieces together.
Update 1 (more info): The deploy from the web page works fine locally with IIS Express - the setup executes from the web page and the .vsto file processes without error. When running the same web application from a dev server, if I click on the link to the setup.exe and download it, I get an error that the .vsto file is not found in the downloads folder. If instead of downloading, I choose to run setup.exe (in IE), then I have the authentication problem, details from the "Installing Office customization" error dialog:
From: http://xxx.xxx.xxx.xxx/ExcelAddIn/ExcelAddInV4.vsto
"Exception reading manifest from http://xxx.xxx.xxx.xxx/Account.LogOn: the manifest may not be valid or the file could not be opened"
Exception Type: System.Deployment.Application.InvalidDeploymentException
Thanks in advance,
Reuven

The Deploying an Office Solution by Using ClickOnce article in MSDN describes all the required steps for creating ClickOnce installers for your Office add-ins. Also you may find the Troubleshooting Office Solution Deployment article helpful.

I was able to work through the issues with this approach:
In Visual Studio and the TFS build the publish points to a UNC file share
After the build I update the publish path in the generated files (vsto, and manifest) with the web site URL using mage.exe. The vsto files are also signed. For the setup.exe, I set the path using the -url command line option (on the setup.exe itself)
I upload these files to the ftp folder that mirror the web site url.
My basic issue was that the deployed files needed to be configured for the eventual web url, but that needed to be a step after the build / deploy in Visual Studio. Once I separated those steps, and set the ClickOnce publish/install location as noted above, in my MVC application linking to the setup.exe in that url worked fine.

Related

Using IIS with Visual Studio 2019 and ASP.NET CORE 3.1

I am running local IIS, and using vs.net 2019 to build web application. All is up and running when I debug-run.
The question/problem quite simply: when I want to modify the cshtml or the enclosed javascript right now I need to restart the web application pushing F5 again. Is there a way I can modify the js/cshtml and just refresh the browser? (this was the workflow I used with .net framework)
You can use 'dotnet watch'. Open Package manager console and navigate to your project folder. Then run 'dotnet watch run'. you can go to browser and visit localhost:5000 (port depends on your configuration) than you will see the app is running. When you change something on cshtml or js file, refreshing the page will reflect the changes to page.

Visual Studio 2017 - Giving remote users access to website in IIS Express

Been looking through and trying all guides i found on this topic but no luck. I am running and MVC project with HTTPS and want to access the debug site with some remote mobile devices to test out the website. I followed a guide that almost work and i think I am pretty close to getting it to work. Here are the steps I have done:
Turn off Firewall
Open projectfolder of website go to \vs\config\ and open applicationhost.config
Find your site and line that contains your mapped port like this:
-edit it to get this result:
Tried to run Visual Studio as Admin at this point, Got regular error 400: Bad Request - Invalid Hostname when trying to access site from other computer
Opened CMD as Admin and ran the following command:
netsh http add urlacl url=http://*:44363/ user=everyone
- URL reservation successfully added
-Tried to start Visual studio as admin and non admin. Gets the following error message
"Unable to launch the IIS Express Web Server.
Failed to reister URL "https://localhost:44363" for site "x" Application. Error description: Cannot create file when that file already exists"
-I then have to run cmd again and remove the url with the command:
netsh http delete urlacl url=http://*:44363/
How do i get this to work with Visual Studio 2017 ? I cant be many steps from getting it to work. I have read many guides but none of them works
Amazing how such a simple common need can be so painful to fulfill out of the box in 2017!
Anyway https://github.com/icflorescu/iisexpress-proxy worked nicely for me.
Install it with node:
npm install -g iisexpress-proxy
Then its just something like:
iisexpress-proxy 51123 to 3000
Under 2 mins to get running.
Let me share my experience with Visual Studio and IIS Express that should help you. I am not using HTTPS and my project type is Web site with WCF but you should be able to accomplish your goal.
Here are prerequisites:
IIS Express installed
Visual Studio installed
Added url reservation for public port (netsh http add url=http://*:50001/ User=Everyone) from elevated command prompt.
Added firewall inbound rule for 50001 TCP port (Control Panel-->Windows Firewall-->Advances Settings-->Inbound Rules-->New Rule...)
Now let us setup a project in VS. I am using one of predefined templates with C#. Compile it and try to run it from VS. At that moment VS is starting developer instance of IISExpress that helps your site to run.
You should be able to see IIS Express icon in Notification area. With right click you will see that your site is running and a port (we will call it VSPORT) that is assigned by VS. This port must be different than reserved port (50001).
If you managed to accomplish this without problems then you have almost everything ready for running your site without VS.
Go to your project folder
Go to .vs folder
Go to config folder
Open applicationhost.config
Locate sites/your_site section
Copy everything between your_site and /your_site
Now we need to add this info in "global" IIS Express config.
Go to IIS Express folder (something like c:\Users\USERNAME\Documents\IISExpress)
Go to config folder
Open applicationhost.config
Locate sites section.
Paste information about your site.
Change binding from
binding protocol="http" bindingInformation="*:VSPORT:localhost"
to
binding protocol="http" bindingInformation=":50001:"
Save changes
With this change you may start IISExpress.exe directly and you can continue to use VS to work on you project at the same time.
If you want to access it from other computers do it as http://YOURIP:50001/.
Do have in mind that you need to ensure that your javascript code is NOT using address and port number directly.
You can solve the problem by downloading the 'conveyor' library from extensions and update in Visual Studio.
You can access it from other devices.
Open Visual Studio
Tools > Extensions and Updates
Online > Visual Studio Marketplace
Search 'Conveyor'
Download and install this extension
When you launch the API, you can access it from other devices. This plugin creates a link from your own ip address.
Example:
https://youripadress:5000/api/values

Deploying asp.net mvc app to folder

I have a hosting running windows, lets say the root domain is xxx.com. On xxx.com there should be website running on php (since IIS can run PHP, right?) or asp.net. I really dont know yet.
I am now responsible of making a asp.net mvc app, which should be running only inside a folder like xxx.com/myaspapp.
I've tried to publish the app straight to the folder via visual studio and it fails with an error:
Server Error in '/' Application.
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.
What is a solution for this? Is this scenario even possible?
Thank you.
WebDeploy can create a virtual application under an IIS site automatically. Check it out:
THE ANATOMY OF A WEBDEPLOY PACKAGE
It is simple to host an application in a sub folder. Follow the below steps.
Create a folder (myaspapp) under the root site path.
Open IIS Manager (inetmgr) and expand till the new folder.
Right the newly created folder and click on Convert to Application.
Deploy/Upload the application files directly to this folder.
Now you will be able to access the site from the sub folder.

Deploying MVC file system publish on IIS7

I have created an MVC application in Visual Studio 2013 and I now wish to deploy this on the IIS of the server so that all employees from within the company will be able to access it via their windows login credentials.
When I run this in localhost via Visual Studio debug it works as expected but I have been trying unsuccessfully to deploy this to a network server and I am unsure of the process and would be grateful for some clarification.
I chose a file system publish from the publish options but I am unsure as to how to get this accessible as an application. I have tried adding the files via the new website wizard and tried the url of 'holidays/' which I had entered but without success. I then tried to add the same virtual directory location as an application from within this website but again this was unsuccessful.
I use Web Deploy with VS. Your target server needs to also have Web Deploy:
Installing and Configuring Web Deploy on IIS 7
Once your target server is ready, you can deploy from VS. Here's a guide on doing that (you can jump right to "Publish to IIS" section if you like):
ASP.NET Web Deployment using Visual Studio
With Web Deploy, you can choose to publish directly or use a deployment package. Once you are happy the publishing works locally, you have a level of confidence your publishing will work in your Live environment.
I would suggest that before you publish direct to a live environment, that you test publish it to your local machine or a test environment that has the same IIS version, and .NET Framework installed.

Migrating Umbraco 4.7

I want to migrate an exsisting Umbraco install from our developer's website into my private virtual server.
I suppose that the server configuration will be different i.e SQL server maybe different version .. ISS .. an so on ..
I wanted to understand what would you recommend as a method to migrate the install ..
I know my way around manually installing web applications (DB, IIS included).. would that be the case if so where can i find a manual on what settings are required to manually install exsisting Umbarco Website on a new server.
And most importantlly what do i need to request from my developer (i.e. files, IIS XML Config backup, SQL DB backup etc..)
There is nothing special about migrating an Umbraco setup to a new server. You'll need a copy of the entire web directory, and a backup copy of the database.
Restore the database to your SQL server, copy the web directory into a directory on your web server, change the connection strings in the web.config to use your SQL server and assuming you have met the prerequisites for running umbraco, you should be good to go.
Alternatively, If you are not sure that your server has everything it needs, you could use the 'Web Platform Installer' to install an empty 4.7.1.1 install, and then copy your developers files over the files installed by the WPI. Going the this route will make the WPI install the prerequisites if you don't have them.
Then you just modify the web.config where necessary to point it to your database server.
EDIT: If your developer has created any custom controls, you'll want to make sure you get copies of the source code for those as well, but you don't need the source to run the site.
You have a couple of options:
If you don't have Remote Desktop access to the developer's server, ask him to give you a Web Deploy package (if he doesn't have Web Deploy already installed, point him here), and install Web Deploy on your own machine. Then you can just right-click on "Web Sites" in IIS and choose "Import Package".
You could purchase Courier, a pro Umbraco add-on which allows you to do full migrations of Umbraco sites between disconnected servers. You set up a blank Umbraco installation from Codeplex, or use Web Platform Installer to get it (get v4.7, not v5, as they're incompatible with one another - v5 uses MVC), install Courier on both the developer site and your live site, and migrate document types, documents, templates, stylesheets, media, and all other necessary resources over to your new environment.

Resources