logo
down
shadow

Creating an MVC Controller Proxy for a Web API Controller


Creating an MVC Controller Proxy for a Web API Controller

By : petrfaitl
Date : November 14 2020, 04:51 PM
I hope this helps you . You can do it by just creating some JsonResult action in your controller which will return result of calling web API.
code :
public class HomeController : Controller
{
    public async Task<JsonResult> CallToWebApi()
    {
        return this.Content(
            await new WebApiCaller().GetObjectsAsync(),
            "application/json"
        );
    }
}

public class WebApiCaller
{
    readonly string uri = "your url";

    public async Task<string> GetObjectsAsync()
    {
        using (HttpClient httpClient = new HttpClient())
        {
            return await httpClient.GetStringAsync(uri);
        }
    }
}


Share : facebook icon twitter icon
Apex why doesn't the standard controller set the current page when creating the controller (Unit Test)

Apex why doesn't the standard controller set the current page when creating the controller (Unit Test)


By : Aditya Dinasty
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , One way to go about this in a test scenario would be something like this:
code :
// at first you have to create the object
DB_Object__c dbObj = new DB_Object__c();
dbObj.Name = 'test';
dbObj.Setting = 'aSetting';
insert dbObj;

// then you'd call the vf page with the id query paramter
Test.setCurrentPageReference(Page.Demo);
ApexPages.currentPage().getParameters().put('id', dbObj.Id);
dbObj = [Select All, Fields, You, Need From DB_Object__c Where Id = :ApexPages.currentPage().getParamters().get('id')];

// then the StandardController & controller extension get initiated
ApexPages.StandardController sc = new ApexPages.StandardController(dbObj);
MyExtension myExt = new MyExtension(sc);
MVC Controller Wizard not appearing when creating a new Controller in VS 2012

MVC Controller Wizard not appearing when creating a new Controller in VS 2012


By : DonFirim
Date : March 29 2020, 07:55 AM
Any of those help It's a Project Guid in the .csproj file that indicates that the project is an ASP.NET MVC project and enables the wizards.
For ASP.NET MVC 4 you need the following:
code :
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
</appSettings>
<ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<appSettings>
    <add key="webpages:Version" value="1.0.0.0" />
</appSettings>
require a parallel directives controller w/o creating a parent controller

require a parallel directives controller w/o creating a parent controller


By : user3017227
Date : March 29 2020, 07:55 AM
I wish this help you I don't think there's a good way to accomplish this "action at a distance". Without some sort of parent-child relationship, there isn't really a way for your directives to find each other (what would Angular do if you had two directiveBs?). Your best bet is probably to use a service to let these directives communicate. It won't change the HTML markup, and it will make it explicit that they have a co-dependency.
To answer your question explicitly: the require relationship is only between a directive and its ancestors.
Error trying to programmatically add a controller file to a navigation controller without creating storyboard

Error trying to programmatically add a controller file to a navigation controller without creating storyboard


By : Footman Mongolia
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , If you are not using a storyboard then you shouldn't attempt to create your sign-in view controller from a storyboard. Change the code to create the view controller directly:
code :
func SignIn(sender: UIButton!) {
    print("I'm, here")
    let controller = signInController()
    self.navigationController?.pushViewController(controller, animated: true)
}
Nested attributes and creating an instance of two separate models in one controller (parent controller)

Nested attributes and creating an instance of two separate models in one controller (parent controller)


By : kb.baby
Date : March 29 2020, 07:55 AM
should help you out You are permitting user_attributes but getting user as params so,
update
code :
<%= form.fields_for :user do |f| %>
<%= form.fields_for :users do |f| %>
 params.require(:tenant).permit(:company, :subdomain,
            user_attributes: [ :email, :first_name, :last_name, :password, :password_confirmation ])
params.require(:tenant).permit(:company, :subdomain,
            user_attributes: [:id, :email, :first_name, :last_name, :password, :password_confirmation ])
Related Posts Related Posts :
  • Can we create and access a registry key in HKEY_LOCAL_MACHINE without running application with admin permissions in C#
  • Control light intensity with a UI slider
  • Threading (Does these threads exits or aborts itself?)
  • Change the function of a button if Logged in
  • how to accept value in date format in textbox in C# windows form?
  • remove the lines from RichtextBox?
  • How to call String.Split that takes string as separator?
  • Specify task timeout in parallel linq to objects
  • comparing two custom objects to prevent duplicates
  • How to Print Text from ComboBox into a MessageBox
  • How can I do a Func<object[],Expression<Func<T,bool>>> dynamic?
  • C# SqlDataReader No data exists for the row/column
  • My code is not giving the desired output
  • Is it possible to have multiple MVC routes point to the same controller/view?
  • Updating Listbox results in " Invalid cross-thread access."
  • Finding Elbow Angle with Kinect
  • Host a mvc web api application in the sub-folder of a website
  • How to generate a sequential unique id in a thread-safe way
  • How to add a separator to a WPF combobox that is databound?
  • optimize linq query with related entities
  • Optimize this code for large input
  • Is there any way to clear all list box short way?
  • ACR122 Device Programming sample does not find reader
  • Parallel Library: does a delay on one degree of parallelism delay all of them?
  • How to convert a var which contains Long to an Long[]
  • Quickly prune and create valid data combinations
  • Get 3 parameters out of a Dictionary<string, Dictionary<string Action>>
  • Regex IsMatch taking too long to execute
  • Shuffling divs using C# behindcode
  • ASP.NET Project and IE10 Compatibility Mode issues in Windows 7
  • Why can't I loop through this dictionary?
  • RavenDB Stream for Unbounded Results - Connection Resilience
  • How to remove the focus border of a CheckBox in C# Visual Studio?
  • Exception while using String.Format "Index (zero based) must be greater than or equal to zero and less than the siz
  • Caching an LDAP connection
  • C# How to detect kill event sender
  • How to Display Splashscreen and login form at same time using c#
  • Read .sql script with parameters
  • Why would I need to compile/generate methods/code at runtime?
  • Unable to create a constant value of type 'Project.Models.Subcategory'. Only primitive types or enumeration types are su
  • How to run possibly synchronous or possibly asynchronous code?
  • Drop SQLite tables using list of tables names
  • Can I organize Git submodules in a flat hierarchy?
  • How to make a server reply after receiving a request/data
  • Stored Procedure works in DB but not in C# code
  • MVVM WPF Programmatically add Child Elements
  • NCrunch and PostSharp Logging clash
  • Increasing memory usage in socket client
  • Multiple DropDownList but same action
  • How to get application memory usage as shown in Task Manager?
  • Exposing interfaces instead of concrete classes
  • How to get only postal_code data from google api?
  • Is there a way to get rid of the (by dot42) using community licence?
  • Why must I implement a function for an interface in vb.net which apparently doesn't need to be implemented in C#
  • How to remove HTML tags from the gridview Row
  • Get public post from Facebook's Graph Search API 2.x with Facebook SDK for .NET
  • C# DLL Export to Inno-Setup - Error E0434F4D
  • syntax error insert into database
  • By-pass else block of int.TryParse in Lambda Syntax
  • Retrieve "property getter" from the property name
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org