Vonage / vonage-dotnet-sdk

Vonage REST API client for .NET, written in C#. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
https://developer.vonage.com/
Apache License 2.0
106 stars 86 forks source link

ASP.NET MVC getting error when click to send I #27

Closed JanieQ closed 7 years ago

JanieQ commented 7 years ago

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I am new to asp.net mvc , It works fine when I run , but when I try to submit , it gives me this error . Sorry If this is a stupid question , I am completely new to asp.net mvc , and I think I'm not completely understand the instruction in readme. Please Help !

smithrobs commented 7 years ago

@JanieQ No problem, here to help. This helps me fix the readme if there is something unclear.

What is probably happening is you are missing some key dependencies in project.json. Using the NuGet console, Install-Package them by issuing the following commands:

Install-Package Microsoft.Extensions.Configuration -version 1.0.1
Install-Package Microsoft.Extensions.Configuration.Abstractions -version 1.0.1
Install-Package Microsoft.Extensions.Configuration.Json -version 1.0.1

You might want to check out the example projects here for comparison: here's the .NET Core version and the .NET Framework version.

Please let me know how it goes. Feel free to join the Nexmo Slack - I'm usually around to chat and help out.

JanieQ commented 7 years ago

Thanks for the reply , I've install the three Package , but still getting the same error .

sidsharma27 commented 7 years ago

Updating those packages in the NuGet Manage to Version 1.0.1 was a part of the fix

Also add the following dependency: Install-Package Microsoft.Extensions.Logging -Version 1.0.1

Please reach out if you have any further issues!

JanieQ commented 7 years ago

It works !! Thank you so much . Just one last one problem , sorry , I should have ask it earlier ,I just realize I can't receive message >< I have create a url using ngrok and point to the localhost port number , and setup in my account with the virtual number I'm using . Then I tried to send a message from my phone but get no response at all.

sidsharma27 commented 7 years ago

Awesome 😄 Glad it worked!

The issue is probably the host header for Ngrok is different than IIS Express so isn't working as planned.

Fix: After specifying which port you wish to host on in the project properties (Navigate to the Web tab, Project URL change the port number to your choosing) EX: http://localost:8080

ngrok http 8080 -host-header="localhost:8080"

That should do the trick! 😄

Please me know if that works for you!

JanieQ commented 7 years ago

Nothing happen . I went to my nexmo account ,and I can see that I have received the message as the dashboard show how many Inbound Message I received today. But I can't read the message that I received .

sidsharma27 commented 7 years ago

What do you have as the Inbound URL in the Nexmo settings? The ngrok url should be there with the correct route. Ex: https://XXXXXXX.ngrok.io/SMS/Recieve

You can try running this quickstart ASP .NET MVC and follow the instructions to receive an SMS with your credentials

JanieQ commented 7 years ago

this is my URL = > http://a5fafe62.ngrok.io/Home/Index , It response 200 OK , so I assume is correct . I'm using NetFrameworkSample.sln .

sidsharma27 commented 7 years ago

In that case, your Index action method inside the Home controller should look something like this then:

[HttpGet]
public IActionResult Recieve([FromQuery]SMS.SMSInbound response)
{
    if (null != response.to && null != response.msisdn)
    {
        Debug.WriteLine("INCOMING TEXT");
        Debug.WriteLine("From: " + response.msisdn);
        Debug.WriteLine(" Message: " + response.text);
        return StatusCode(200);
    }
    else
    {
        Debug.WriteLine("Endpoint hit.");
        return StatusCode(200);
;   }
}

I would recommend referring to the quickstart as I am successfully able to recieve SMS

JanieQ commented 7 years ago

sorry for the late reply , I've tested it out , and using the quickstart works for me too , Thank You ^^

sidsharma27 commented 7 years ago

Glad to hear it 😄 Feel free to reach out with any other questions!