locked
Modals working in servel local but no working in server internet RRS feed

  • Question

  • User-966490163 posted

    Hello everybody.

    I have a problem that I could not solve as much as I searched the internet. I have a modal on my page that works on my local server but when I publish my project in the hosting (SmarterASP.NET) it loads the modal but empty, it is as if the route was not loading it. with another script that probe throws me a route error, but I have no idea what it really can be. This is the address of my page where I have the problem http://newera-airconditioning.be/Home/Portfolio. you will notice that I have a test link on top of the image, that is a script and the image has the other one, both of them I think they give me the same error

    My Controller

    public async Task<IActionResult> Modals(int? id)
            {
                if (id == null)
                {
                    return NotFound();
                }
    
                var portfolio = await _context.Portfolio.Include(x => x.Image)
                    .SingleOrDefaultAsync(m => m.PortfolioId == id);
                if (portfolio == null)
                {
                    return NotFound();
                }
    
                return PartialView("Modals", portfolio);
            }

    My Modal

    @model NewEra.Models.MisModel.Portfolio
    
        <div class="close-modal" data-dismiss="modal">
            <div class="lr">
                <div class="rl"></div>
            </div>
        </div>
        <div class="container">
            <div class="row">
                <div class="col-lg-8 mx-auto">
                    <div class="modal-body">
                        <h3 class="text-uppercase">@Model.Name</h3>
                        <p class="item-intro text-muted">@Model.Description</p>
                        <img class="img-fluid d-block mx-auto" src="data:image/jpeg;base64,@Convert.ToBase64String(Model.Image.Picture)" alt="">
                        <p>Description</p>
                        <ul class="list-inline">
                            <li><span style="font-weight:bold">Date:</span> @Model.FechaDone.ToShortDateString()</li>
                            <li><span style="font-weight:bold">Client:</span>  @Model.Cliente</li>
                            <li><span style="font-weight:bold">Modelo:</span> @Model.Modelo</li>
                        </ul>
                        <button class="btn btn-primary" data-dismiss="modal" type="button">
                            <i class="fas fa-times"></i>
                            Close Project
                        </button>
                    </div>
                </div>
            </div>
        </div>
    

    my links to call the modal


    <a href="javascript:void(0);" class="anchorDetail" data-id="@item.PortfolioId">Details</a>
    <a class="portfolio-link" data-value="@item.PortfolioId">

    My scripts

    $(document).ready(function () {
        $(".portfolio-link").click(function () {
            var id = $(this).data("value");
            $("#ContenedorModal").load("/Portfolios/Modals/" + id, function () {
                $("#modal-container").modal("show")
            });
        });
    });
    
    
    var TeamDetailPostBackURL = '/Portfolios/Modals';
    $(function () {
        $(".anchorDetail").click(function () {
            debugger;
            var $buttonClicked = $(this);
            var id = $buttonClicked.attr('data-id');
            var options = { "backdrop": "static", keyboard: true };
            $.ajax({
                type: "GET",
                url: TeamDetailPostBackURL,
                contentType: "application/json; charset=utf-8",
                data: { "Id": id },
                datatype: "json",
                success: function (data) {
                    debugger;
                    $('#myModalContent').html(data);
                    $('#myModal').modal(options);
                    $('#myModal').modal('show');
                },
                error: function () {
                    alert("Dynamic content load failed.  " + TeamDetailPostBackURL);
                }
            });
        });
        $("#closbtn").click(function () {
            $('#myModal').modal('hide');
        });
    });
    

    I hope someone can help me because I'm already exhausted. Clarify that I have two scripts because I am testing the application and it gives me the same problem. Thanks in advance.

    Sunday, August 11, 2019 3:50 PM

Answers

  • User1520731567 posted

    Hi Josh010316,

    According to your link,I find it reports error 401 Unauthorized.

    I suggest you could try tp add [AllowAnonymous] attribute on ajax action to avoid certification,

    if your need certification indeed,You need to consider if there are some settings(such as: Windows Authentication,Forms Authentication ...e.g.) that need to be enabled on SmarterASP.NET.

    Since SmarterASP.NET is a platform for charging,the forum can't reproduce your question.

    But I tried to seek help from the online customer service on SmarterASP.NET, he has upgraded your question.

    And you could also ask for help to their official website.

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2019 7:27 AM

All replies

  • User1520731567 posted

    Hi Josh010316,

    According to your link,I find it reports error 401 Unauthorized.

    I suggest you could try tp add [AllowAnonymous] attribute on ajax action to avoid certification,

    if your need certification indeed,You need to consider if there are some settings(such as: Windows Authentication,Forms Authentication ...e.g.) that need to be enabled on SmarterASP.NET.

    Since SmarterASP.NET is a platform for charging,the forum can't reproduce your question.

    But I tried to seek help from the online customer service on SmarterASP.NET, he has upgraded your question.

    And you could also ask for help to their official website.

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2019 7:27 AM
  • User-966490163 posted

    Hi Yuki

    Thank you. Your suggestion [AllowAnonymous] I suppose it should go in the controller that deals with that method. I would like you to be a little more specific if it doesn't bother you. I think it's really something that I have to keep in mind but I really don't understand what he wants to tell me. And it will have to do something that the modal does not work for me on the server?

    Best Regards.

    Josh

    Monday, August 12, 2019 9:08 PM