Mail Merge via Web API - c#

I have a C# Web API and Web Application that is an all-in-one program. This project is going to be hosted on my company's intranet. I'm attempting to setup a mail merge process within this Web API using Microsoft.Office.Interop.Word. It works just fine when debugging. The mail merge template file is hosted at C:\inetpub\wwwroot\MailMergeTemplate\Template.docx.
However, this stops working as soon as I deploy the website to IIS. Every time I attempt to run the merge I'm met with a HTTP 500 Internal Server Error. I tried to move the template to a mapped network drive but that didn't work. I also made a different web directory for the template via IIS and put the file in there. I could browse to the folder via Chrome just fine and could see and download the template. But this didn't work either.
How should I host a mail merge template so the Web Application can see it and access it? Is this even possible?

Related

How to fix the 500 internal server error when deploying a web application to an ASP.NET framework VM on google cloud?

I am trying to deploy a simple ASP.NET web application over the Internet, using the google cloud platform. I followed the tutorial on this page : https://cloud.google.com/dotnet/docs/getting-started/hello-world (I uploaded a slightly more complex app though). So basically everything went well from the creation of the ASP.NET framework virtual machine to the deployment from my computer to the VM since I've been able to reach for the web app home page through the VM IP address.
Starting Web deployment task from source: manifest(C:\Users...\obj\Release\netcoreapp2.2\PubTmp\myApp.SourceManifest.xml) to Destination: auto().
Updating file (Default Web Site\MyApp.deps.json).
Updating file (Default Web Site\MyApp.runtimeconfig.json).
Updating file (Default Web Site\web.config).
Successfully executed Web deployment task.
Problem is that the home page won't display as it did when I would deploy it locally (with IIS express) but rather throw an
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
I found some interesting subjects raising the same issue :
Deploying website: 500 - Internal server error : suggests to enable detailed errors and/or to change a few lines in the web.config file but I do not have a web.config file at my side of the process in my project (only a Startup.cs which does some of the work) and I cannot manipulate the one in the google virtual machine.
I noticed that before uploading the web app to the VM, the output displayed errors similar to these : https://github.com/dotnet/sdk/issues/1897 (message NETSDK1041) so I thought that the discrepancies between referenced/platform assemblies might be the origin of these errors but then, why wouldn't they impact the local deployment of the web-app too ?
I would like my web application to run on google cloud's VM (based on the generic Google Compute Engine ASP.NET framework), the web app is 'correctly' deployed to the host VM but raises a wild 500 - internal error. Anybody has any idea as to how I could at least identify the source of this error ? (Helping me find the web.config would also help greatly, I understand that everybody has this file somewhere, but I can't find it and don't have a clue on its whereabouts because I just used a random template MVC application on Visual Studio Community 2017 which did all the configuration work

What is the difference between Publish methods provided in the Visual Studio?

When I click on the Publish method following options show up:
What is the significance of each method?
Web Deploy - If you have IIS on server machine running and configured to receive Web Deploy requests, it will send all requested by IIS files. IIS will immediately start running new web page.
Web Deploy Package - If you have IIS on server machine running and configured to receive a Web Deploy Package it will pack your whole web page, and will upload them to server machine. IIS will immediately start running new web page.
FTP will upload files to FTP server (can be any OS that handles FTP), but be aware that this is NOT safe and whole upload process can be captured and compromised.
File system will deploy all items required for launching a web service, with any method supported by current project configuration, into provided directory on your machine.
Web Deploy:
Deploys your app to a local or remote IIS server immediately (one click publishing), assuming you have access and the server is configured properly.
Web Deploy Package:
Similar to Web Deploy, but creates a zipped deployment package on the local file system to be deployed later to a local or remote IIS server.
FTP:
Copies the required app files to an FTP server. You might use this to deploy your app to the (non-Azure) cloud.
File System:
Copies the required app files to the local file system. Useful for testing or if you want more control over how the deployment is done.
The two web deploy methods are smarter than the more old-school FTP/file system approaches. For example, they can apply config file transforms during the deployment, and they are faster because they only transfer changes. They are also more secure.
More info here.

Azure Mobile Services on IISExpress gives me the error - web server is not configured to list the contents of this directory

After update for the latest AzureMobile.Services.Backend.Tables package, when i try to run my application at IISExpress or LocalIIS appears this error:
Web server is not configured to list the contents of this directory.
Im aware that azure mobile service which is an asp.net web api does not have an home page which is generate on runtime.I tried to create a new azure mobile services and it works fine as well.
Am I missing something on my webconfig?
Solved by creating another project of Mobile Services with an default template.

Starting a ASP.NET restful webservice on IIS

I have developed a restful web service using ASP.NET, and while using the Visual Studio environment, it worked like a charm with IIS Express. The service itself is a complementary feature and will have to run on every machine on which our product is installed.
I have therefore created a new directory webservice, which holds the web.config and the Global.asax file, as well as a directory bin, which holds the RestulWebservice.dll file.
I then have setup a new web page on the IIS, rooting at C:\inetpub\wwwroot. The web page itself is hosting a web application, based in C:\inetpub\wwwroot\RestfulWebservice (which holds the files described above).
However, if I startup the IIS and visit http://localhost:80/RestfulWebservice, all I am getting is an error 403.14, stating that I may not inspect the contents of this folder unless I allow IIS to do so. If I choose to allow this, I am simply presented with the contents of the folder, not the service itself.
If I try to access a resource of the restful web service directly (i.e. http://localhost:80/RestfulWebservice/Home, I get a direct 404.0 error, telling me that the resource does not exist)
What am I doing wrong here, it can impossibly be this hard to get a compiled library ASP.NET web service to run on the IIS, it works like a charm on IIS express.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

Access bat file outside web folder in c#

What I am trying to do:
I have a bat file that I want to execute via a button on the web page. This web page will then execute the command responses while the process is running.
I have managed successfully to get the bat file to run on my button click and output the responses on the page on my localhost, however I am sure I will encounter permission issues when I deploy my app onto qa,staging,production server. The reason being because the bat file is outside the web folder and I'm sure the error will be something like Access Denied
The web application is run using form authentication on a win2003 running IIS6.
The bat file is outside the web root as it sits under a application we deploy via a wix that includes a suite that has services, libraries, etc under it.
I thought about using impersonation but when looking on the web all the examples I found were for Windows authentication so I'm guessing I can rule this option out.
Any advice will be much appreciated
Kind Regards
Zal

Categories

Resources