created a new view but that view only outputs the html (of the login page!)
I am pretty sure I have been missing out something very trivial, so I appreciate another set of eyes again.
Context: I made a new view (JumpToDashboard) on my simple ASP.NET core app in addition to the default Index and Privacy views.
Whenever the browser runs the app and accesses to the JumpToDashboard page it only turns to the whole html of the login page (as per screenshot- I already found this embarassing). It was supposed to display a view with the title dashboard.
I have tried moving around those tags [AllowAnonymous] [Authorize]. Still, JumpToDashboard always returns that embarrassing html
https://pastebin.com/jCtNzRG6 This is my code, could anyone kindly point me in the right direction?
Pastebin
/Controller Class/using System.Diagnostics;using Microsoft.AspNet...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
15 Replies
Well, you are fetching whatever gets displayed at
localhost:5001
and returning it as JSON
So the code does exactly what you told it to
In a blocking way, might I add, since you're using .Result
instead of await
ing properlyI see, thank you so much for helping me understand this code. I am very new to this.
Could you give me some hint to await that properly (or do you have some links)?
Instead of
you write
yeah, id guess that changing the mime type would do the trick. Id also rename "string json" to something else like responseString or something.
Question is, though: why are you fetching the HTML from
localhost:5001
and returning it, instead of just... redirecting there?
You're doing twice the work for zero benefitMaybe they are creating some kind of relay? proxy? idk lol
wasnt the ask
When someone asks "how do I eat soup with a fork" you say "use a spoon", even though that wasn't the ask either lol
Ryan Laughs
YouTube
SOLVED! Can't Drink Soup with A Fork #lifehacks #funny
#lifehacks #funny #shorts
Cheap and Cool Tech Accessories: https://amzn.to/3EawMWu
Cheap and Cool Gaming Accessories: https://amzn.to/3nkfEXF
Cheap and Cool Office Accessories: https://amzn.to/3vzvOAa
🗡️Buy Me A Knife🗡️ https://www.buymeacoffee.com/BigFishTech
❤️ SUPPORTING THE CHANNEL by shopping at Amazon via our affiliate link: https://amz...
it's just everything was so new to me that I have no idea where I was fetching the HTML from
Please bear with me asking this stupid question: what is the mime type you are referring to?
text/html i believe
line 66
Ahh ok
ContentType = "application/json",
So my uneducated guess is: if I keep application/json like this the app will display the bunch of HTML on the browser, right?
I assume changing this would do the trick
If you want to keep this... uh, "innovative" idea instead of using a redirect, yes
You will be returning HTML after all, not JSON
well this innovative idea came from AI, ofc not from me. No idea what kind of company needs an app like this, returning HTML instead of JSON :kekw:
I ended up adding this line
return Redirect(requestUrl)
I hope this is what you meantYes, that's how you redirect
considering we do non-sensical things all the time where I work, I wouldn't be surprised if they have something like it lol