0
votes

Php and html file run perfectly on hosting but when i try to run my asp.net core 2.1 web app its can not execute on hosting server. its php code and here is asp core web code

this is asp core web uploaded file and folder publish from visual studio

Program.cs

public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>();
    }
2
Are you sure that your hosting server supports asp.net ?Moien Tajik
How did you host asp.net core 2.1? What is your hosting server? The error returns is 403, I would suggest you split php and asp.net core web hosting for a try.Edward
publish from visual studio into system file then upload on hosting server and hosting server is linux. Please give me a proper way to do this other then ms docs.Jagdish Kumar

2 Answers

1
votes

I answered a similar question I believe the following answer will be useful to you. You want to use the built in publish feature with a custom profile to upload directly from VS https://stackoverflow.com/a/53860224/10782174

0
votes

Are you sure that you have deployed your project properly? The following is steps to publish your .net core:

Step 1: Download VS 2017 from Microsoft website

Step 2: Open solution within vs 2017, you will be told once this happens, you can no longer open the project within vs 2015, however they do backup automatically a version at 2015

step 3: The xproj file at the heart of the application is transformed into a csproj file. This filetype is now editable by right clicking on the Main project heart within the directory, and selecting edit {!ProjectName}.csproj, it should open an XML file format.

step 4. Add these lines to the project. (Please note, the project may contain some of these lines already).Some has to add the runtimeidentifiers and supperdocker targets to a property group that already existed.

step 5. Open the project within the command prompt in the usual method (where you right click the project name, open file explorer at the project location and then crtl+shift clicking within the file explorer and selecting the open with command prompt option.

Step 6. Run: dotnet publish -c Release -r win7-x64 within the command prompt NOTE: Please run the following command: npm install -g bower - within the nugget package manager console, this is meant to install bower globally or something along those lines. This process will publish a self-contained application of your project within the root directory>Bin>Release>Win64>publish

Please do not forget to add the following lines:

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<RuntimeIdentifiers>win7-x64;win7-x86;ubuntu.16.04-x64;</RuntimeIdentifiers>
<SuppressDockerTargets>True</SuppressDockerTargets>
</PropertyGroup>

I would recommend you to use Windows server. You can use asphostportal.com and they support .net core.