Widget upgrade 3.8 to 4.5 PublicInfo Post Method

3 months ago
G'day Lads,
i  am having a problem with the publicInfo Post method as title says so i am using view component with invokeasync to show the widget (works as get method similarly) on main page it works fine but when i want to retrieve the information to my controller to be able to do operations on it in PublicInfo in my controller it never hits the action so i am assuming there is routing problem but i dont know how to fix it
so to give you a better insight
here is my publicinfo.cshtml under views snippet starting off with script to do some stuff with calendar and show the calender and then added a part ( hoped it would sort the issue called is-complete)

<script>
        $(function () {
            #other operations
          
            [code]$(".is-complete").change(function () {

                

                let AppointmentDate = $(this).data("AppointmentDate");
                let AppointmentReason = $(this).data("AppointmentReason");
                let ContactName = $(this).data("ContactName");
                let ContactNumber = $(this).data("ContactNumber");

                console.log($(this).data("AppointmentDate"));

                $.ajax({
                    type: "POST",
                    url: '/WidgetsFullCalendar/PublicInfo',
                    data: {
                        AppointmentDate: AppointmentDate, // Use a colon here
                        AppointmentReason: AppointmentReason, // and here
                        ContactName: ContactName, // and here
                        ContactNumber: ContactNumber, // and here
                    },
                    headers: {
                        "RequestVerificationToken":
                            $('input:hidden[name="__RequestVerificationToken"]').val()
                    },
                  
                });

            });

and then

                 <div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-dismiss="modal">@T("Admin.Common.Cancel")</button>
    <button type="submit" class="btn btn-primary is-complete">@T("Admin.Common.Save")</button>
</div>

so i have save a button after the user clicks save it should call that function is-complete and pass the data to the controller this is my understanding so far from 4.5 you did not need this in 3.8 or 4.1 but now since i have viewcomponent and it gets the get method from viewcomponent somehow i need to define post method publicinfo for this form


allready tried some other things like :
made a route configuration in my routeprovider.cs

endpointRouteBuilder.MapControllerRoute("Plugin.Widgets.FullCalendar.PublicInfo", "Plugins/WidgetsFullCalendar/PublicInfo",
         new
         {
             controller = "WidgetsFullCalendar",
             action = "PublicInfo"
         });

and then also in my controller did something like this

        [Route("Plugins/Widgets.FullCalendar/PublicInfo")]

and i dont think i can include the post method in my view component can i ?!

if you need further documents feel free to reach me or you can have a look at the github page
https://github.com/misogare/updating_booking/tree/main/Nop.Plugin.Widgets.FullCalendar
            
cheers
3 months ago
I've looked into your problem and found a problem with your URL. 😁😁

https://prnt.sc/zp49MGJztONj

DM me to learn more.
I support you.
3 months ago
Your ajax URL probably needs to be

   url: "@Url.Action("PublicInfo", "WidgetsFullCalendar")",