From Wikipedia, the free encyclopedia
Computing desk
< April 3 << Mar | April | May >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


April 4 Information

ASP.NET Core and Angular

I've been told at work that the web application I've been developing in ASP.NET Core needs to use Angular for better responsiveness. I understand ASP.NET Core but I'm a complete beginner in Angular.

I've tried a simple login page where the page uses Angular to send an AJAX POST request to the ASP.NET Core controller something like this:

$.post("/Login/UserLogin", { username: username, password: password }).done(function (data) { /* ... */ });

where the /Login/UserLogin goes to a normal ASP.NET Core controller method that returns a ViewResult containing the "you're now logged in" page. But I'm at a loss about how to show it. In the example call above, data in the done() function appears to contain the rendered HTML code of the page. How do I get the /* ... */ part to actually show it in the browser? JIP | Talk 18:21, 4 April 2019 (UTC) reply

If I understand correctly, you want to use a string escape sequence to prevent '/' and '*' (and indeed the rest of the block comment) from being interpreted as a code comment; and to be passed through the interpreter as "plain text" and eventually output to the HTML. Syntax for this is documented in Mozilla's Javascript reference, Strings § Escape notation; or in Microsoft's CLR documentation if your ASP code is written in c or C# or similar language.
By its nature, this type of thing gets messy - you've potentially got comment syntax in multiple languages, with the intermediate text results potentially being parsed by multiple interpreters; so you may need one or more nested layers of escape-ment. Is there a way you can simply avoid doing this altogether?
Nimur ( talk) 03:32, 5 April 2019 (UTC) reply
No, you don't understand me correctly. The comment is just a placeholder to use in this Wikipedia message. What I want to know is, once I get the HTML source code of the page in the $.post call, how do I actually display it on the page in JavaScript? JIP | Talk 05:28, 5 April 2019 (UTC) reply
Among the options, you can write JavaScript that manipulates the final output document, using API like Document.getElementById to select what you're modifying; and write() to add content. If this isn't working, we'll need to find a resource who has better expertise in the exact setup you've got, to help troubleshoot. Nimur ( talk) 15:07, 5 April 2019 (UTC) reply
From Wikipedia, the free encyclopedia
Computing desk
< April 3 << Mar | April | May >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


April 4 Information

ASP.NET Core and Angular

I've been told at work that the web application I've been developing in ASP.NET Core needs to use Angular for better responsiveness. I understand ASP.NET Core but I'm a complete beginner in Angular.

I've tried a simple login page where the page uses Angular to send an AJAX POST request to the ASP.NET Core controller something like this:

$.post("/Login/UserLogin", { username: username, password: password }).done(function (data) { /* ... */ });

where the /Login/UserLogin goes to a normal ASP.NET Core controller method that returns a ViewResult containing the "you're now logged in" page. But I'm at a loss about how to show it. In the example call above, data in the done() function appears to contain the rendered HTML code of the page. How do I get the /* ... */ part to actually show it in the browser? JIP | Talk 18:21, 4 April 2019 (UTC) reply

If I understand correctly, you want to use a string escape sequence to prevent '/' and '*' (and indeed the rest of the block comment) from being interpreted as a code comment; and to be passed through the interpreter as "plain text" and eventually output to the HTML. Syntax for this is documented in Mozilla's Javascript reference, Strings § Escape notation; or in Microsoft's CLR documentation if your ASP code is written in c or C# or similar language.
By its nature, this type of thing gets messy - you've potentially got comment syntax in multiple languages, with the intermediate text results potentially being parsed by multiple interpreters; so you may need one or more nested layers of escape-ment. Is there a way you can simply avoid doing this altogether?
Nimur ( talk) 03:32, 5 April 2019 (UTC) reply
No, you don't understand me correctly. The comment is just a placeholder to use in this Wikipedia message. What I want to know is, once I get the HTML source code of the page in the $.post call, how do I actually display it on the page in JavaScript? JIP | Talk 05:28, 5 April 2019 (UTC) reply
Among the options, you can write JavaScript that manipulates the final output document, using API like Document.getElementById to select what you're modifying; and write() to add content. If this isn't working, we'll need to find a resource who has better expertise in the exact setup you've got, to help troubleshoot. Nimur ( talk) 15:07, 5 April 2019 (UTC) reply

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook