1

I'm using an html template with plugin fullcalendar. I need load event from database using events as a json feed

There are many example to do this with $.ajax but I want to use native plugin tools.

Who I can do this with asp.net? I'm using webform.

Thanks in advance

Update: I've created a webservice to return JSON data. This is the code:

Imports System.Web.Script.Serialization

Imports System.Web.Script.Services Imports System.Web.Services

<WebService([Namespace]:="http://tempuri.org/")>
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
<System.ComponentModel.ToolboxItem(False)>
Public Class Calendar
    Inherits System.Web.Services.WebService

    Public Class DateCalendario
        Public Property Title As String
        Public Property Start As String
        Public Property myEnd As String
    End Class


    <WebMethod>
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
    Public Sub GetCalendarDate(Start as string, EndDate As String)
        Dim obj As  DateCalendario()
        obj = New DateCalendario() {New DateCalendario() With {
            .Title = "Evento di prova",
            .Start = "2020-12-05T09:00:00",
            .myend = "2020-12-05T18:00:00"
        }, New DateCalendario() With {
            .Title = "Evento di test",
            .Start = "2020-12-07T09:00:00",
            .myend = "2020-12-07T18:00:00"
        }}

        Dim js As JavaScriptSerializer = New JavaScriptSerializer            
        Context.Response.Write(js.Serialize(obj))
    End Sub
End Class

Problem is that I cannot use word end to set class property name so I've used myend. Also when RUN webpage return an error: "Failed to load resource: the server responded with a status of 500 (Internal Server Error)" with this URL: http://localhost:49988/Webservice/Calendar.asmx/GetCalendarDate?start=2020-11-30&end=2021-01-11&_=1607451959751

Whats wrong? Someone can post a correct sample to return correct data. According plugin documentation this is an example that work:

[
{
  "title": "Event 1",
  "start": "2019-09-05T09:00:00",
  "end": "2019-09-05T18:00:00"
},
{
  "title": "Event 2",
  "start": "2019-09-08",
  "end": "2019-09-10"
}

]

Searching log on my PC found this problem:

Event code: 3005 Event message: Eccezione non gestita. Event time: 09/12/2020 14:14:32 Event time (UTC): 09/12/2020 13:14:32 Event ID: d435a05e13d647bcadaa423135ba29b4 Event sequence: 32 Event occurrence: 3 Event detail code: 0 Application information: Application domain: /LM/W3SVC/2/ROOT-2-132519685992168059 Trust level: Full Application Virtual Path: / Application Path: C:\Users\corradolembo\Documents\Visual Studio 2019\WebSite\DupigestADV\ Machine name: CORRADOLEMB975D Process information: Process ID: 14848 Process name: iisexpress.exe Exception information: Exception type: InvalidOperationException Exception message: Formato della richiesta non riconosciuto. L'URL termina in modo imprevisto con '/GetCalendarDate'. in System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) in System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) in System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) in System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() in System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
in System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) Request information: Request URL: http://localhost:49988/Webservice/Calendar.asmx/GetCalendarDate?start=2020-11-30&end=2021-01-11&_=1607519672582

Request path: /Webservice/Calendar.asmx/GetCalendarDate User host address: ::1 User:
Is authenticated: False Authentication Type: Thread information: Thread ID: 25 Is impersonating: False Stack trace: in System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) in System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) in System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) in System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() in System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
in System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

What is the problem?

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • Can you please add the code you tried for?. Remember that you can edit your question in order to add a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – ricardo-dlc Dec 08 '20 at 17:04
  • `Problem is that I cannot use word end to set class property name `...yes you can - see https://stackoverflow.com/questions/5868777/can-i-use-a-keyword-as-a-propertyname-in-vb-net – ADyson Dec 08 '20 at 20:51
  • Anyway a 500 internal server error is just a generic message. It tells you that the server crashed, but not why. For that you should probably look in the windows event log of the server (and/or any other log, if you application has another logging system). – ADyson Dec 08 '20 at 20:53
  • Hello ADyson this is log event: – user2231301 Dec 09 '20 at 13:18
  • I don't see anything? If you have extra info, please use the "edit" button to add it to your question. Don't put log data, code, error messages or anything else like that into the comment section. – ADyson Dec 09 '20 at 13:22
  • Exception information: Exception type: InvalidOperationException Request information: Request URL: http://localhost:49988/Webservice/Calendar.asmx/GetCalendarDate?start=2020-11-30&end=2021-01-11&_=1607519672582 Request path: /Webservice/Calendar.asmx/GetCalendarDate Thread information: Stack trace: in System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) in – user2231301 Dec 09 '20 at 13:25
  • cannot paste all information – user2231301 Dec 09 '20 at 13:25
  • Again: **If you have extra info, please use the "edit" button to add it to your question** . Then you will have plenty of space. And again: **Don't put log data, code, error messages or anything else like that into the comment section**. – ADyson Dec 09 '20 at 13:38
  • Ok. One thing I noticed is in the webmethod you have `Start as string, EndDate As String`, but that fullCalendar sends parameters named `start` and `end`. Also I don't see why you are treating them as `string` - .NET should be able to parse them if you declare the parameters as `DateTime`. So try making sure the parameter names align and see if that helps. Unfortunately these legacy ASMX webmethods are notorious for producing unhelpful or generic error messages. Web API and WCF-based services are easier to work with. – ADyson Dec 09 '20 at 13:58
  • Hi ADyson, I've modified name second parameter and tried again but nothing. Same error: Exception message: Request format not recognized. The URL unexpectedly ends with '/ GetCalendarDate'. – user2231301 Dec 09 '20 at 14:39
  • The names may be case sensitive, they need to be `start` and `end` not `Start` and `End`. Try that. – ADyson Dec 09 '20 at 14:48
  • Also, IDK if https://stackoverflow.com/questions/657313/request-format-is-unrecognized-for-url-unexpectedly-ending-in would help you. If you type "webmethod The URL unexpectedly ends with" into Google, you will also get a lot of other useful-looking results. – ADyson Dec 09 '20 at 14:49

0 Answers0