locked
Communicating react with asp.net core on remote server (httpdocs folder) does not work RRS feed

  • Question

  • User1493762548 posted

    hi all, i have built two saparate projects client(react with redux) and webapi (asp.netcore). both working fine and communicating on localhost.now i purchased windows hosting and uploaded both in httpdocs folder in plesk file manager as follows:

    server (asp.netcore webapi ) deployment:

    in webapi. i changed the url in program.cs from "http://localhost:4000" to https://www.virtualcollege.pk as:

    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Hosting;
    
    namespace WebApi
    {
        public class Program
        {
            public static void Main(string[] args)
            {
                CreateHostBuilder(args).Build().Run();
            }
    
            public static IHostBuilder CreateHostBuilder(string[] args) =>
                Host.CreateDefaultBuilder(args)
                    .ConfigureWebHostDefaults(webBuilder =>
                    {
                        webBuilder.UseStartup<Startup>()
                          .UseUrls("http://www.virtualcollege.pk");
                    });
        }
    }



       then  published to local folder and copied whole published folder to httpdocs folder on remote folder .there was web.config file on httpdocs which did not replaced otherwise it did not work.

    Client Deployment:    i changed the url in web.config.js from "http://localhost:4000" to https://www.virtualcollege.pk  then in client used "npm run build" command which produced dist folder on root :

     dist folder has two files;

    1.index.html

    2.main-bundle.js

      i uploaded both files to same httpdocs folder on remote server.the website works but front-end does not interact with back-end . .here is link of live website : https://www.virtualcollege.pk

    the error is 404 for api call when port in url is :443

    the error is "connection time out " for api call when port in url is 4000 . note the 4000 ,3000 both are opened by hosting provider in firewall.

    thanks in advance for help.

    regards 

    fiaz ahmed ranjha

    Thursday, August 13, 2020 3:28 AM

All replies

  • User1493762548 posted

    hi all, i i mixed the web.config files the one which is already present and the one which i did not uploaded from published folder .now the back-end works but the index.hml file does not returned so the new error is : 

    This www.virtualcollege.pk page can’t be found

    No webpage was found for the web address: https://www.virtualcollege.pk/

    the web.config files is ;

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <location path="." inheritInChildApplications="false">
        <system.webServer>
        <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
          </handlers>
                <aspNetCore processPath=".\WebApi.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="outprocess" />
    
            <httpErrors>
                <remove statusCode="502" subStatusCode="-1" />
                <remove statusCode="501" subStatusCode="-1" />
                <remove statusCode="500" subStatusCode="-1" />
                <remove statusCode="412" subStatusCode="-1" />
                <remove statusCode="406" subStatusCode="-1" />
                <remove statusCode="405" subStatusCode="-1" />
                <remove statusCode="404" subStatusCode="-1" />
                <remove statusCode="403" subStatusCode="-1" />
                <remove statusCode="401" subStatusCode="-1" />
                <remove statusCode="400" />
                <error statusCode="400" path="D:\inutpub\virtualcollege.pk\error_docs\bad_request.html" />
                <remove statusCode="407" />
                <error statusCode="407" path="D:\inutpub\virtualcollege.pk\error_docs\proxy_authentication_required.html" />
                <remove statusCode="414" />
                <error statusCode="414" path="D:\inutpub\virtualcollege.pk\error_docs\request-uri_too_long.html" />
                <remove statusCode="415" />
                <error statusCode="415" path="D:\inutpub\virtualcollege.pk\error_docs\unsupported_media_type.html" />
                <remove statusCode="503" />
                <error statusCode="503" path="D:\inutpub\virtualcollege.pk\error_docs\maintenance.html" />
                <error statusCode="401" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\unauthorized.html" />
                <error statusCode="403" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\forbidden.html" />
                <error statusCode="404" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\not_found.html" />
                <error statusCode="405" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\method_not_allowed.html" />
                <error statusCode="406" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\not_acceptable.html" />
                <error statusCode="412" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\precondition_failed.html" />
                <error statusCode="500" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\internal_server_error.html" />
                <error statusCode="501" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\not_implemented.html" />
                <error statusCode="502" prefixLanguageFilePath="" path="D:\inutpub\virtualcollege.pk\error_docs\bad_gateway.html" />
            </httpErrors>
        </system.webServer>
        </location>
    </configuration>
    

    i think there is some thing to tweak in web.config or startup.cs files.</div> </div> </div> </div> </div>

    Friday, August 14, 2020 3:48 AM
  • User932909087 posted

    Hi fiazah,

    I browse your site and I see error message "you don't have pemission to visit this site". Please make sure you have deployed your files properly on the server and setup your own default page. To deploy .net core, you may also refer to this post https://windowswebhostingreview.com/how-to-build-simple-asp-net-core-website/

    Tuesday, August 18, 2020 4:47 AM