How can I implement this type of redirect after post method in MVC

I am currently creating an MVC app that is currently getting a value from a post from a webhook. I think the problem is that the application gets the value from the POST verb, but then it doesn't display it because the Get verb is used to display the view, so both verbs act against each other.

The webhook will successfully run the Json payload for my application because I have code that will send the Json payload to a variable via email to my email account.

Dim body = issue.issue.key
mail.Body = body

      

It's in the try catch block, because for it to have a value, it must have a value in it, and the app will do a GET first, so it's null "> strong>, then the POST gets the value, but it doesn't display the value the update will just do a GET so that it doesn't show up How can I do both at the same time so I can display the value in the ViewBag for example.

ViewBag.response = status + key

      

This is the type of structure that I would like to implement in order to try and fix the error, but I don't know how to complete all the steps:

enter image description here

This is what I got so far:

POST comes from webhook and I read it like this.

Dim reader As System.IO.StreamReader = New System.IO.StreamReader(HttpContext.Request.InputStream)
Dim rawSendGridJSON As String = reader.ReadToEnd()
Dim tempVar As Rootobject = JsonConvert.DeserializeObject(Of Rootobject)(rawSendGridJSON)
System.Diagnostics.Trace.TraceError(rawSendGridJSON)

      

Then I try to store the post values ​​in a table like this:

Public Function CallBack(tempTable as temporaryTable)
    Dim tempVar As Rootobject = JsonConvert.DeserializeObject(Of Rootobject)(rawSendGridJSON)
tempVar = temporaryTable.tempVar

      

Then I save the new items to an actual table in the database, then I try to display it in a view on another page. This is not working correctly and the problem is with this line, as the message is not being read correctly at the right time. (The value is being handled correctly as I can use the email method to send the variables in the email back to the application, but that application needs to be efficient real-time code.)

Is there a better way to use this method and how can I call this process that I want to do correctly so that I can display the correct information?

Update

To clarify, there are two entries that occur, the first is when a user enters information and submits it. It is then stored in the database and sent to JIRA via email. When JIRA receives the information, it sends an HTTP POST webhook JSON Payload back to my app with the updated information. Then I deserialized the JSON Payload into a variable called issueKey .

The problem is that the view page that the information is sent to will automatically display a null value before that value is sent, I want the application to work so that it actually displays / stores values ​​from the payload in the database Webhook JSON, but I can't figure out how to display the values.

Now I have set up a communication channel from SignalR to my MVC app, at the time MVC got it, and I have installed the SignalR chat hub in my MVC app, but I don’t know how to integrate them, how can this be done?

+3


source to share


1 answer


As I understand it, there are two streams here. User submits data that triggers an email to Jira. Then after a while (usually pretty fast, but not always) JIRA launches the web app in the web app with some updated information, and you want to somehow display this updated information to the user, or at least inform the user when an updated information from JIRA.

I would follow the standard Post-Redirect-Get for the user initiated portion (as per br4d's comment). That is a message to store data in the database and send email to jira that returns a redirect to get that shows the data stored in the database.



Now for the other part, I would use signalr to set up some kind of communication channel for the user. The Webook can then send a signal (sorts) through the communication channel to the users browser and either display the data or trigger a page refresh (if you are updating the database with data from Jira).

It is not clear if you are doing straigt mvc or some kind of SPA application, but it is not very important. The users browser is not aware of the web site (which is part of the web application and is not associated with the users session) and you need some kind of communication between the web application and the browser and this signal is very good.

+1


source







All Articles