Base solution for your next web application
Open Closed

Asp.net core anf Angular2 cli issue. #2775


User avatar
0
sunilpaul033 created

Hello I download the project and run asp.net core successfully. But when I run angular CLI with npm load it to browser. I am getting a internal server error. So please anybody can help me. Url which not return response: "http://localhost:22742/AbpUserConfiguration/GetAll"

Please also tell me the file for routing process in asp.net core aplication. Thanks in advance.

Regards Sunil Paul


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share error message ? Maybe a screenshot ? By the way, arae you running free angular2 template or AspNet Zero's angular2 template ?

    Because free template runs on <a class="postlink" href="http://localhost:21021/">http://localhost:21021/</a>.

    Thanks.

  • User Avatar
    0
    bpieslak created

    Hi - I am also encountering the same issue. I compile and start the asp.net core server and the Swagger UI starts. I then compile and start the angular UI using npm start, and then then I browse to <a class="postlink" href="http://localhost:4200/">http://localhost:4200/</a>, I immediately encounter an "internal server error" message in the browser.

    the cURL for the failing request I see is the following:

    curl "http://localhost:21021/AbpUserConfiguration/GetAll" -H "Pragma: no-cache" -H "Origin: <a class="postlink" href="http://localhost:4200">http://localhost:4200</a>" -H "Accept-Encoding: gzip, deflate, sdch, br" -H "Abp.TenantId: null" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -H "Content-Type: application/json" -H "Accept-Language: null" -H "Accept: application/json, text/javascript, /; q=0.01" -H "Cache-Control: no-cache" -H "Authorization: Bearer null" -H "Connection: keep-alive" -H "Referer: <a class="postlink" href="http://localhost:4200/">http://localhost:4200/</a>" --compressed

    and the response content is:

    {"result":null,"targetUrl":null,"success":false,"error":{"code":0,"message":"InternalServerError","details":null,"validationErrors":null},"unAuthorizedRequest":false,"__abp":true}

    Aside from modifying the connectionString to use localhost\sqlexpress, I haven't changed anything else.

    I am following the instructions documented here: <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Zero/Startup-Template-Angular">https://aspnetboilerplate.com/Pages/Doc ... te-Angular</a>

    also to note - I am also seeing an Internal Server Error response when I attempt to test the Token Based Authentication per the documentation. using the Restlet Client Chrome Extension, and submitting a POST request to localhost:21021/api/TokenAuth/Authenticate with the correct Content-Type and request body, I get the same response:


    {"result":null,"targetUrl":null,"success":false,"error":{"code":0,"message":"InternalServerError","details":null,"validationErrors":null},"unAuthorizedRequest":false,"__abp":true}

    and lastly - I don't see anything in the log4net logs or in the Visual Studio 2017 console output.

    Thanks for any help you can offer. -Brian

  • User Avatar
    0
    bpieslak created

    I think I may have figured it out. I downloaded a new gemplate and went back to the instructions page here: <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Zero/Startup-Template-Angular">https://aspnetboilerplate.com/Pages/Doc ... te-Angular</a>

    and made sure I followed the steps as closely as possible. I think previously I had skipped this step:

    "In order to create your database, open command prompt and move to root folder of EntityFramework project in your solution. Then run "dotnet ef database update" command.""

    so I ran that first. then I went into my appsettings.json and update my connectionString from localhost to localhost\sqlexpress

    Then continued on with the angular ui project, running "npm install" and then "npm start", and now I see the expected login page here: <a class="postlink" href="http://localhost:4200/account/login">http://localhost:4200/account/login</a>

    and checking the Network tab in the Chrome Developer Tools, for the previous /GetAll endpoint request that was failing, I now see a successful 200 response.

    and I am able to login successfully with the default admin credentials.

    the only other potential step I took that was different was that I made sure that every time I opened Visual Studio, that I opened with Administrator privileges (I need to set that up to open automatically)

    sunilpaul033 - confirm that you ran the dotnet ef database update command noted in the setup instructions. That appears to be the step that I had forgotten previously. I am going to go back to the first project I downloaded and see if running that command fixes my error.

  • User Avatar
    0
    bpieslak created

    just to close the loop on my earlier post, I went back to my original project and ran dotnet ef database update and now it works. I no longer get the 500 Internal Server Error on the /GetAll endpoint, I see the login page when I go to <a class="postlink" href="http://localhost:4200/">http://localhost:4200/</a> and I am able to login with the default admin credentials.

    Hope this helps others! -Brian

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks @bpieslak.