question

DanHowitt-2125 avatar image
0 Votes"
DanHowitt-2125 asked ZhiLv-MSFT commented

Visual Studio Publish MVC website

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


dotnet-aspnet-core-mvc
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi anonymous user,

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).

Can you post the detailed error message? When you deploy/host the application, please make sure all the file was published include the database.

The error messages seem to point at my local files using absolute path

In your application try to use the relative path, instead of the absolute paths.

Besides, based on your description, it is hard to reproduce the problem and understand your question. Because we don't know which version of Asp.net you are using and what you did in your code. So if possible, I suggest you could tell us the details what you did and the related code. Or you can create a simple sample to reproduce the problem.

Best regards,
Dillion

0 Votes 0 ·

0 Answers