C#C
C#3y ago
xdd

✅ Server side or Client side?

Hi, finally i get to MVC and it looks much easier then work with minmal api, so i have some questions about it. should i use views for 100% of my htmlpages? like, as i get, cuz mvc is just part of net core, instead of return View() i can use app.UseDefaultFiles(); and i thing it gonna work without any problem, is it bad tone to mix ways of rendering? also, in old project i was requesting data with fetch and rendering it like this -
async function LoadProduct() {
    const response = await fetch(`/api/product`, {
        method: "GET",
        headers: { "Accept": "application/json" }
    });

    if (!response.ok)
        console.error();

    const data = await response.json();
    const div = `
        <div class="product-container">
            <div class="product-image">
                <img class="product-img" src="../${data.image}" alt="Product Image">
            </div>
            <div class="product-details">
                <p class="titleq pp">${data.title}</p>
                <p class="priceq pp">${data.price}$</p>
                <p class="descriptionq pp">${data.description}</p>
            </div>
        </div>
        `

    document.querySelector("[data-container]").insertAdjacentHTML("beforeend", div);
};
Was this page helpful?