Click here to Skip to main content
14,662,330 members
Home » Discussions » ASP.NET
   

ASP.NET

 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Richard Deeming23-Feb-20 21:16
mveRichard Deeming23-Feb-20 21:16 
QuestionUpdating two related tables in asp.net core Pin
ElenaRez16-Feb-20 18:35
MemberElenaRez16-Feb-20 18:35 
QuestionBinding combox in gridview with selected value of another comboBox Pin
BikerMonkey14-Feb-20 9:01
professionalBikerMonkey14-Feb-20 9:01 
QuestionHow to get a field's value from a linq query Pin
ElenaRez12-Feb-20 3:09
MemberElenaRez12-Feb-20 3:09 
AnswerRe: How to get a field's value from a linq query Pin
Richard Deeming12-Feb-20 4:45
mveRichard Deeming12-Feb-20 4:45 
QuestionStill having some display problems Pin
samflex7-Feb-20 5:36
Membersamflex7-Feb-20 5:36 
QuestionHow to set starting page or controller method of a web application when we are deploying the React or Angular or Ember applications Pin
simpledeveloper6-Feb-20 14:35
Membersimpledeveloper6-Feb-20 14:35 
AnswerRe: How to set starting page or controller method of a web application when we are deploying the React or Angular or Ember applications Pin
jkirkerx7-Feb-20 10:01
professionaljkirkerx7-Feb-20 10:01 
In Angular, the home page is set in App.Routes.ts.
{ path: "", redirectTo: "home", pathMatch: "full" },
So any wild card path that doesn't match another route gets sent to website.com/home, and the home.routes.ts takes it from there. Or if you type https://website.com/legal, the legal.routes.ts calculates the route.
{ path: "", component: HomeComponent },
{ path: "legal", loadChildren: "./legal/legal.module#LegalModule" },
{ path: "", redirectTo: "", pathMatch: "full" }
This allows typing https://website.com to load the home page https://website.com/home
Or allows sending a link to a page to share such as https://website.com/software/Angular

I suspect your thinking old school, like setting up IIS and setting the programs root folder to start from.
SPA in Setup.cs just tells SPA where the ng build root is, and calls the npmScript "start" in package.json. What SPA services really does is compiles or builds angular when you start the project.
"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build:ssr": "ng run jkirkerx:server:dev",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postInstall": "npm rebuild node-sass"
},
The controller say .Net Core V2.2+ if that is what your using for back end logic has it's own routes that you assign to a controller. So this is the Store Controller, and is called by an Angular service as
https://website.com/api/Store/GetBrands/1/8
[Produces("application/json")]
[Route("api/[controller]")]
[ApiController]
public class StoreController : ControllerBase {

  [HttpGet("GetBrands/{page}/{show}")]
  public async Task<GetBrands> GetBrands(int page, int show)
  {
    return await _brandsRepository.GetBrands(page, show);<br />
  }

}
With CORS setup correctly, only the client can call this Url, and if typed in the browser, Angular will reject the request and your Startup.cs will direct the request to the https://website.com/Error
if (env.EnvironmentName.Equals("Development"))
{
    app.UseDeveloperExceptionPage();
}
else
{
    app.UseExceptionHandler("/Error");
    app.UseWhen(context => !context.Request.Path.Value.StartsWith("/api"), builder =>
    {
        builder.UseStatusCodePagesWithReExecute("/Error/{0}");
    });

    app.UseHsts();
    app.UseHttpsRedirection();
}
I've only done a Angular app wrapped in .Net Core V2.2+, and the two seem to bounce off each other in terms of Web hosting and protection if you program the Kestrel Web Server in Program.cs and Startup.cs. I could separate the 2 projects from each other and still formulate a solution that works in a Docker Container.

But like I said in the past, designing and building the hosting environment, testing it and fully understanding it is a huge project in itself with very little documentation on how to do it. I learned the hard way on how to program Kestrel, and then do it in a Docker Container. Something I will write a paper on here soon if anyone is interested in it.
If it ain't broke don't fix it
Discover my world at jkirkerx.com

GeneralRe: How to set starting page or controller method of a web application when we are deploying the React or Angular or Ember applications Pin
simpledeveloper7-Feb-20 12:50
Membersimpledeveloper7-Feb-20 12:50 
QuestionHow do I solve InvalidCaseUserControl.Dispose(bool) no suitable method found to override Pin
Member 114033043-Feb-20 7:36
MemberMember 114033043-Feb-20 7:36 
AnswerRe: How do I solve InvalidCaseUserControl.Dispose(bool) no suitable method found to override Pin
Richard Deeming3-Feb-20 7:46
mveRichard Deeming3-Feb-20 7:46 
GeneralRe: How do I solve InvalidCaseUserControl.Dispose(bool) no suitable method found to override Pin
Member 114033043-Feb-20 8:11
MemberMember 114033043-Feb-20 8:11 
QuestionIn need of direction for project Pin
led3-Feb-20 7:31
Memberled3-Feb-20 7:31 
AnswerRe: In need of direction for project Pin
phil.o3-Feb-20 23:14
mvephil.o3-Feb-20 23:14 
GeneralRe: In need of direction for project Pin
led4-Feb-20 6:21
Memberled4-Feb-20 6:21 
GeneralRe: In need of direction for project Pin
phil.o4-Feb-20 6:38
mvephil.o4-Feb-20 6:38 
Question.net core Swagger code gen Pin
manoj62931-Jan-20 14:28
Membermanoj62931-Jan-20 14:28 
QuestionIIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
holdorf31-Jan-20 5:30
Memberholdorf31-Jan-20 5:30 
AnswerRe: IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
Richard Deeming31-Jan-20 5:49
mveRichard Deeming31-Jan-20 5:49 
GeneralRe: IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
holdorf31-Jan-20 6:51
Memberholdorf31-Jan-20 6:51 
GeneralRe: IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
Richard Deeming31-Jan-20 7:13
mveRichard Deeming31-Jan-20 7:13 
GeneralRe: IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
holdorf31-Jan-20 7:50
Memberholdorf31-Jan-20 7:50 
QuestionSQL and IIS error when publish an ASP .NET application to IIS Pin
holdorf30-Jan-20 12:54
Memberholdorf30-Jan-20 12:54 
AnswerRe: SQL and IIS error when publish an ASP .NET application to IIS Pin
phil.o30-Jan-20 13:07
mvephil.o30-Jan-20 13:07 
QuestionHow do I solve error StatusCode: 500? Pin
Member 1140330430-Jan-20 4:01
MemberMember 1140330430-Jan-20 4:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.