✅ Redirect ASP.NET

Hi. I would like to insert styles on the page first, and then output a JSON file, but I don't understand how to do it.
30 Replies
NullReference
NullReferenceOP2y ago
I tried everything I knew.
x0rld
x0rld2y ago
why you want to load css like that ? 🤔 why not use the css injector classic in asp.net core ?
NullReference
NullReferenceOP2y ago
I am beginner. I don't know what is this😅
x0rld
x0rld2y ago
ah you are using razor for the views ?
NullReference
NullReferenceOP2y ago
ok, i will try it :/
x0rld
x0rld2y ago
it's like that for razor ( the .cshtml files )
@section styles {
<link href="@Url.Content("~/your/path/index.css")" rel="stylesheet" type="text/css" />
}
@section styles {
<link href="@Url.Content("~/your/path/index.css")" rel="stylesheet" type="text/css" />
}
NullReference
NullReferenceOP2y ago
I am just learning controllers. I haven't used view yet))
x0rld
x0rld2y ago
it's an api ? 🤔
NullReference
NullReferenceOP2y ago
idk😅 I found a website for studying ASP.NET . And first they teach you how to use controllers
x0rld
x0rld2y ago
can you give me the link
NullReference
NullReferenceOP2y ago
ASP.NET Core MVC | Полное руководство
Полное руководство по созданию веб-приложений с помощью фреймворка ASP.NET Core MVC на языке программирования C#
NullReference
NullReferenceOP2y ago
its russian site so, I am also from Russia😅
x0rld
x0rld2y ago
np thanks to translator 😂
NullReference
NullReferenceOP2y ago
))
x0rld
x0rld2y ago
in the chapter 1 there is views 🤔 https://metanit.com/sharp/aspnetmvc/1.3.php
NullReference
NullReferenceOP2y ago
But it does not describe how to work with them
x0rld
x0rld2y ago
oh yeah oh ok you are in the second chapter ?
NullReference
NullReferenceOP2y ago
yeah I know that since I am nobody does. But I just wanted to do something of my own with what I know now.
x0rld
x0rld2y ago
public class HomeController : Controller
{
public string Index()
{
string tomJson = JsonSerializer.Serialize(tom,jsonSettings);
return $"{yourStyleContent}{tomJson}";
}
public class HomeController : Controller
{
public string Index()
{
string tomJson = JsonSerializer.Serialize(tom,jsonSettings);
return $"{yourStyleContent}{tomJson}";
}
you can do something like that @NullReference you understand ?
NullReference
NullReferenceOP2y ago
i'm tryinng it now one sec
NullReference
NullReferenceOP2y ago
NullReference
NullReferenceOP2y ago
error 406
x0rld
x0rld2y ago
show me where did your write the code
NullReference
NullReferenceOP2y ago
I fixed the bug issue, but now it looks like this
x0rld
x0rld2y ago
oh 🤔 let me try something
NullReference
NullReferenceOP2y ago
I could!
Response.ContentType = "text/html";
Response.ContentType = "text/html";
NullReference
NullReferenceOP2y ago
x0rld
x0rld2y ago
maybe oh yeah didn't think about that xD
NullReference
NullReferenceOP2y ago
Thanks!!! You are the best)))
x0rld
x0rld2y ago
👌 you can close with /close

Did you find this page helpful?