Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 days ago.
Improve this question
I just want to ask of how connecting the api to adobe esign what I have done is created a free account on esign, all I have is Client ID: Value: and Integration Name
Here's the details, I don't know how to connect, how should I get response , what I did is just locating the pdf file on my API and I want to pass it on adobe esign, any idea pls help thanks
Integration Name: IntegLocalTest
Name: TestAPIDotNet
Client ID: CBJCHBCAABAAwZbeuYdCnrx11U9Tc5uAndaQDtrQcVFk
Redirect URI: https://secure.sg1.adobesign.com/account/accountSettingsPage#pageId::API_APPLICATIONS
Value: M6X5UhM15oKUnaEAFniAeRQktgW5BlXA
Here is my code:
----------------
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.IO;
namespace ApiReadData.Controllers
{
[Route("[controller]")]
[ApiController]
public class PDFController : ControllerBase
{
[Route("load-from-folder")]
[HttpGet]
public async Task<IActionResult> LoadPdfFromPhysicalLocation()
{
string physicalPath = "wwwroot/pdf/quitclam.pdf";
byte[] pdfBytes = await System.IO.File.ReadAllBytesAsync(physicalPath);
MemoryStream ms = new MemoryStream(pdfBytes);
return new FileStreamResult(ms, "application/pdf");
}
}
}
Next is How can I connect to Adobe esign using this details
atleast the first step is to get a response
enter image description here
I'm expecting, the setup code on .json file, and the startup code controller, atleast the starting code how can I get a response connecting on adobe esign
Related
My controller for one of my WebAPIs was working perfectly yesterday, but today I made some changes to projects outside of the actual controller code and now the API is not posting correctly. This is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Markup;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace SanTool_WebAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class GeneratorStatusController : ControllerBase
{
static List<string> strings = new List<string>()
{
"value0", "value1", "value2"
};
[HttpGet]
public List<string> GetValues()
{
return strings;
}
[HttpPost("{input}")]
public List<string> Post(string input)
{
strings.Add(input);
return strings;
}
}
}
When I run the code using IIS explorer, and then navigate to https://localhost:44312/GeneratorStatus/, it displays my [HttpGet] correctly (displays the three strings), but when I try to use the post request with, https://localhost:44312/GeneratorStatus/2, it gives me error 405 and doesn't return the string
If you are just changing the URL in chrome this would be the problem. 405 often will mean that you are using the wrong http request type. When just changing the URL browsers issue a GET request to that resource.
You may want to test that same POST method with Postman.
Also see: Asp.Net Core 3.1 405 Method Not Allowed
First thing first.
I could be wrong here, but https://localhost:44312/GeneratorStatus/2, is something I would only use when I am getting things. In my experience, I have never seen a POST URL that looks like that.
Second,
I think, you are doing the Post wrong. First Up, I hope you are using Postman or curl to test your endpoints.
your POST would be something like this.
URL - If I am POSTing, the URL would be
https://localhost:44312/GeneratorStatus
with the Post Body, in your case, is a simple string, would look something like this.
{
input : "some input value"
}
Your Controller should probably look like this.
[HttpPost]
public List<string> Post(string input)
{
strings.Add(input);
return strings;
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Am just wondering how to solve this. I need to automate my company website. There I need to navigate more than one url for a multiple web pages. I have designed Hybrid framework along with Page object Model Design.
My Requirement is,
say I have 3 url's :
www.google.com
www.yahoo.com
Facebook
All the above url and its test data I will keep in an Excel sheet. I have created three different pages and three different test classes.
So my list of questions are:
How to pass url's one by one to [setup] method
how to call the test method deepening upon the url type
Execution Flow need to implement of Application:
You need to parametrize your test with TestCase attribute.
[TestCase("www.google.com")]
[TestCase("www.yahoo.com")]
[TestCase("www.facebook.com")]
public void WebPageTest(string site)
{
driver.Url(site);
//continue with the test.
}
See this article to learn more: https://github.com/nunit/docs/wiki/TestCase-Attribute
Storing URL in excel is not good idea,
You may store URL in app.config file and by using ConfigManager utility you may retrieve those URL from app.config file
As according to your test cases you can use URL where its needed and required
I would suggest you to use [category] attribute to categorise your test cases. For example
[Test]
[Category("GoogleTest")]
public void googletest1()
{
}
[Test]
[Category("FBTest")]
public void fbtest1()
{
}
Now in the [SetUp] method you can load url based on the category, something like
[SetUp]
public void testsetup()
{
#initialise driver
var category = TestContext.CurrentContext.Test.Properties.Keys;
if(category.Contains("GoogleTest"))
{
//category1 setup
}
else if(category.Contains("FBTest"))
{
//category2 setup
}
}
So using this method you can solve query # 2, i.e the url related to the test is already loaded for you, so you can continue with your tests after setup
I'm familiar with PHP and JS, as well as MVC methodology, but I'm completely new to C# and have spent time looking for the documentation on this specific error.
I used dotnet new mvc to create a working app on port 5000. Also note, I am working in the Controller, not the model or view:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ExelonPrime.Models;
namespace OptimusPrime.Controllers{
public class ApiController : Controller
{
public void Help_Pdf()
{
Response.Write("test");
}
}
}
And the error I get (when trying to compile) is:
error CS1061: 'HttpResponse' does not contain a definition for 'Write' and no accessible extension method 'Write' accepting a first argument of type 'HttpResponse' could be found (are you missing a using directive or an assembly reference?)
If I'm missing a using directive, which one is it? I tried System.Web and that didn't work. How do I make this work?
I would recommend following through microsofts tutorial on using asp.net core.
https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/?view=aspnetcore-2.2
As far as this specific instance, rather than using Response.Write, I would do this
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SampleWeb.Models;
namespace SampleWeb.Controllers
{
public class ApiController : Controller
{
[HttpGet]
public ActionResult<string> Help_Pdf()
{
return "test";
}
}
}
This specific sample might be helpful.
With this class, the url https://localhost:5001/api/Help_Pdf returns "test"
In ASPNET Core, when writing an API, it's more common to return an object, or POCO in stead of directly writing to the response stream (although it indeed is possible)
try changing your
public void Help_Pdf()
{
Response.Write("test");
}
to
[HttpGet()]
public IActionResult Help_Pdf()
{
return Ok();
}
this will return an 204 (no content), you can pass data however, to the OK function, to add a body to the response object.
If your trying to write directly to the response stream like that, you can do this:
public async Task Help_Pdf()
{
await Response.WriteAsync("Test");
}
However, I'd recommend not doing this in your actual app, the method should return an IActionResult. IMO it's not good practice to write directly to the stream in your controller methods (not very test friendly).
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
In my account controller I have something like this:
var result = await UserManager.CreateAsync(user, model.Password);
foreach (var error in result.Errors)
{
modelstateErrors.Add(error);
}
Every error string is localized in English language
What's the best practice in localizing ASP.NET Identity error messages?
Are there any libraries with localized errors, and how are they implemented?
Would it be good idea to switch on every ASP.NET Identity error and return your own localized string?
To localize ASP.Net Identity you need to install one of the following Nuget packages from the Nuget store => https://www.nuget.org/packages?q=Microsoft.AspNet.Identity.Core
You install the package that belong to your culture. So for French culture you should install Microsoft.AspNet.Identity.Core.fr
They all follow the pattern Microsoft.AspNet.Identity.Core.[Culture] where [Culture] is the code fo the culture.
Create e base controller and extend every controller from it
public class BaseController : Controller
{
protected override void OnException(ExceptionContext filterContext)
{
// verify which kind of exception it is and do somethig like logging
}
}
It is one of the best practice por handlling errors, but for the localizing itself do what #codeNotFound said.
I want to make my MVC4 web application log in using Google or Facebook. I've read that uncommenting the line OAuthWebSecurity.RegisterGoogleClient() of the AuthConfig.cs is enough to set it up but it doesn't work for me. The login page is still showing the advice "There are no external authentication services configured..." and the providers buttons don't appear.
Details:
- MVC 4
- VS 2013
- Using C#
- Using the internet aplication template
---------------------------------this is my AuthConfig.cs file------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Web.WebPages.OAuth;
using Tarea3.Models;
namespace Tarea3
{
public static class AuthConfig
{
public static void RegisterAuth()
{
// To let users of this site log in using their accounts from other sites such as Microsoft, Facebook, and Twitter,
// you must update this site. For more information visit http://go.microsoft.com/fwlink/?LinkID=252166
//OAuthWebSecurity.RegisterMicrosoftClient(
// clientId: "",
// clientSecret: "");
//OAuthWebSecurity.RegisterTwitterClient(
// consumerKey: "",
// consumerSecret: "");
//OAuthWebSecurity.RegisterFacebookClient(
// appId: "",
//appSecret: "");
OAuthWebSecurity.RegisterGoogleClient();
}
}
}
Ask for more details, thanks!
Edited: I made a new project and it just works fine. But i dont know what im doing wrong in my main project. What are the reasons it could be happening?
Check if you are registering Auth in Global.asax (something like this: AuthConfig.RegisterAuth();)
Read the tutorial provided by Microsoft, please:
http://www.asp.net/mvc/tutorials/security/using-oauth-providers-with-mvc