Visual Studio Publish MVC website

Dan Howitt 1 Reputation point
2021-11-05T15:27:14.023+00:00

Hi
I have built a MVC website in Visual Studio Pro 2017 using C#. When I run it within Visual Studio, it works as I would expect, no problems. However when I publish it and try to use it via IIS I run into a number of problems, and I dont understand why.

If i create a blank template website and move that to the same IIS location, it works. But as soon as I add anything useful to it, I just have problems I dont understand.

So these are:

  • I created a custom class C# file to handle authentication with Active Directory, I make reference it to prevent certain views being opened by particular groups and redirecting where necessary. It works fine in VS but outside of it, it throws an out of bounds error message -both in my project and the blank template (replicating the functionality).
  • When I remove the references to the custom class file I get DB access failure messages - but I've specified in the connection string to use a service account which works within Visual studio.

The error messages seem to point at my local files using absolute paths - as though its trying to access files in the original location it was developed within visual studio, why would it do this? I am totally confused.

Any help would be greatly appreciated!

Thank you
Dan

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,157 questions
{count} votes