Custom OData Route Not ResolvingThe path template on the action in controller is not a valid OData path templateWebAPI OData can't deal with dots (i.e. '.') in a parameter?Cannot implement multiple GET methods in WebApi ODataOdata web api 404 errorOData paging with expand issueHow to change route in WebApi+Odata projectEnableDependencyInjection in OData extension libraryOData filter with “and” operator not working in Web ApiWebApi oData v3 Entity Data Model routingIs it possible to config multiple routes with ODATAASP.MVC WebAPI Odata routing for two or more controller methods
Shoteh in the gemara
Public Salesforce Site and Security Review
Game of Life meets Chaos Theory
Is Cola "probably the best-known" Latin word in the world? If not, which might it be?
How did Arya manage to disguise herself?
Is lying to get "gardening leave" fraud?
Does hiding behind 5-ft-wide cover give full cover?
LT Spice Voltage Output
How to get SEEK accessing converted ID via view
Floor tile layout process?
Selecting a secure PIN for building access
Melee attacking upwards (enemy on 10ft ceiling)
Why was the pattern string not followed in this code?
Why are notes ordered like they are on a piano?
If Melisandre foresaw another character closing blue eyes, why did she follow Stannis?
Is it the same airport YUL and YMQ in Canada?
Problems with numbers (result of calculations) alignment using siunitx package inside tabular environment
If Earth is tilted, why is Polaris always above the same spot?
Why do freehub and cassette have only one position that matches?
Post Endgame, how is the flow of time different?
Sower of Discord, Gideon's Sacrifice and Stuffy Doll
If 1. e4 c6 is considered as a sound defense for black, why is 1. c3 so rare?
What word means "to make something obsolete"?
I lost my Irish passport. Can I travel to Thailand and back from the UK using my US passport?
Custom OData Route Not Resolving
The path template on the action in controller is not a valid OData path templateWebAPI OData can't deal with dots (i.e. '.') in a parameter?Cannot implement multiple GET methods in WebApi ODataOdata web api 404 errorOData paging with expand issueHow to change route in WebApi+Odata projectEnableDependencyInjection in OData extension libraryOData filter with “and” operator not working in Web ApiWebApi oData v3 Entity Data Model routingIs it possible to config multiple routes with ODATAASP.MVC WebAPI Odata routing for two or more controller methods
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to set up a custom OData route for a Web API project that I am building. The intent is that I would like to be able to pass a parameter through the route to filter the results.
The route is never resolving to my method, I am getting a 404 error when I try to navigate to it in the browser.
I followed the suggestion at the bottom of the accepted answer for this question.
In case the link is dead, that means I attempted to register a function to my ODataModelBuilder and set it to accept a parameter.
First, I want to register a function in WebApiConfig.cs, like the example showed. That is done as:
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<myEntity>("Employees");
var function = builder.Function("GetByEmail");
function.Parameter<string>("Email");
function.ReturnsFromEntitySet<myEntity>("Employees");
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: null,
model: builder.GetEdmModel()
);
Now, I have a method that I want to route to. Inside EmployeesController.cs I have the following method:
[EnableQuery]
[ODataRoute("GetByEmail(Id=email)")]
public SingleResult<myEntity> GetByEmail([FromODataUri] string email)
var test = email; // I have a breakpoint sitting here to see if I ever get into the function.
...
I'm never actually getting into this function.
When I hit the route http://localhost:49707/GetByEmail(email=abc), I get the .Net framework error "Server Error in '/' Application".
Just for testing, when I hit the route http://localhost:49707/GetByEmail, I get an XML error that reads "No HTTP resource was found that matches the request URI".
As you might guess, the expected outcome is that I can get this URI to properly route to my function.
I can perform all of the operations I need to once I get into this function but I am new to OData routing, and I just cannot figure out what I am missing for the reference question.
c# asp.net-web-api odata
add a comment |
I am trying to set up a custom OData route for a Web API project that I am building. The intent is that I would like to be able to pass a parameter through the route to filter the results.
The route is never resolving to my method, I am getting a 404 error when I try to navigate to it in the browser.
I followed the suggestion at the bottom of the accepted answer for this question.
In case the link is dead, that means I attempted to register a function to my ODataModelBuilder and set it to accept a parameter.
First, I want to register a function in WebApiConfig.cs, like the example showed. That is done as:
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<myEntity>("Employees");
var function = builder.Function("GetByEmail");
function.Parameter<string>("Email");
function.ReturnsFromEntitySet<myEntity>("Employees");
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: null,
model: builder.GetEdmModel()
);
Now, I have a method that I want to route to. Inside EmployeesController.cs I have the following method:
[EnableQuery]
[ODataRoute("GetByEmail(Id=email)")]
public SingleResult<myEntity> GetByEmail([FromODataUri] string email)
var test = email; // I have a breakpoint sitting here to see if I ever get into the function.
...
I'm never actually getting into this function.
When I hit the route http://localhost:49707/GetByEmail(email=abc), I get the .Net framework error "Server Error in '/' Application".
Just for testing, when I hit the route http://localhost:49707/GetByEmail, I get an XML error that reads "No HTTP resource was found that matches the request URI".
As you might guess, the expected outcome is that I can get this URI to properly route to my function.
I can perform all of the operations I need to once I get into this function but I am new to OData routing, and I just cannot figure out what I am missing for the reference question.
c# asp.net-web-api odata
add a comment |
I am trying to set up a custom OData route for a Web API project that I am building. The intent is that I would like to be able to pass a parameter through the route to filter the results.
The route is never resolving to my method, I am getting a 404 error when I try to navigate to it in the browser.
I followed the suggestion at the bottom of the accepted answer for this question.
In case the link is dead, that means I attempted to register a function to my ODataModelBuilder and set it to accept a parameter.
First, I want to register a function in WebApiConfig.cs, like the example showed. That is done as:
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<myEntity>("Employees");
var function = builder.Function("GetByEmail");
function.Parameter<string>("Email");
function.ReturnsFromEntitySet<myEntity>("Employees");
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: null,
model: builder.GetEdmModel()
);
Now, I have a method that I want to route to. Inside EmployeesController.cs I have the following method:
[EnableQuery]
[ODataRoute("GetByEmail(Id=email)")]
public SingleResult<myEntity> GetByEmail([FromODataUri] string email)
var test = email; // I have a breakpoint sitting here to see if I ever get into the function.
...
I'm never actually getting into this function.
When I hit the route http://localhost:49707/GetByEmail(email=abc), I get the .Net framework error "Server Error in '/' Application".
Just for testing, when I hit the route http://localhost:49707/GetByEmail, I get an XML error that reads "No HTTP resource was found that matches the request URI".
As you might guess, the expected outcome is that I can get this URI to properly route to my function.
I can perform all of the operations I need to once I get into this function but I am new to OData routing, and I just cannot figure out what I am missing for the reference question.
c# asp.net-web-api odata
I am trying to set up a custom OData route for a Web API project that I am building. The intent is that I would like to be able to pass a parameter through the route to filter the results.
The route is never resolving to my method, I am getting a 404 error when I try to navigate to it in the browser.
I followed the suggestion at the bottom of the accepted answer for this question.
In case the link is dead, that means I attempted to register a function to my ODataModelBuilder and set it to accept a parameter.
First, I want to register a function in WebApiConfig.cs, like the example showed. That is done as:
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<myEntity>("Employees");
var function = builder.Function("GetByEmail");
function.Parameter<string>("Email");
function.ReturnsFromEntitySet<myEntity>("Employees");
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: null,
model: builder.GetEdmModel()
);
Now, I have a method that I want to route to. Inside EmployeesController.cs I have the following method:
[EnableQuery]
[ODataRoute("GetByEmail(Id=email)")]
public SingleResult<myEntity> GetByEmail([FromODataUri] string email)
var test = email; // I have a breakpoint sitting here to see if I ever get into the function.
...
I'm never actually getting into this function.
When I hit the route http://localhost:49707/GetByEmail(email=abc), I get the .Net framework error "Server Error in '/' Application".
Just for testing, when I hit the route http://localhost:49707/GetByEmail, I get an XML error that reads "No HTTP resource was found that matches the request URI".
As you might guess, the expected outcome is that I can get this URI to properly route to my function.
I can perform all of the operations I need to once I get into this function but I am new to OData routing, and I just cannot figure out what I am missing for the reference question.
c# asp.net-web-api odata
c# asp.net-web-api odata
asked Mar 22 at 19:59
bluemoon6790bluemoon6790
628
628
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307010%2fcustom-odata-route-not-resolving%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307010%2fcustom-odata-route-not-resolving%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown