OData / OData/WebApi

VirtualPathRoot is null in owin self-hosted environment

Open
#976 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
C#
Stars
864
Forks
467
PR merge metrics
No merged PRs in 30d

Description

System.ArgumentNullException is raised when receiving batch requests due to VirtualPathRoot is null in owin self-hosted environment

Reproduce steps

Create a Owin Self-Hosted WebApi Application (Odata V4) and register ODataBatchHandler as in below code to handle Odata batch request.

public void Configuration(IAppBuilder app)
 {
   ...

   HttpConfiguration config = new HttpConfiguration()
   ODataBatchHandler batchHandler = new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer);

   ...

   config.EnsureInitialized();

 }

Send a Batch request to Odata end point.

Expected result

Batch request should be prosessed.

Actual result

An Exception is occured.
Value cannot be null. Parameter name: virtualPathRoot ExceptionType : System.ArgumentNullException

Additional details

GlobalConfiguration.DefaultServer.Configuration.VirtualPathRoot is null in Self Hosted App but VirtualPathRoot has a value = "/" in ISS hosted environment.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Owin self-hosted Web API setup with DefaultODataBatchHandler and a batch request. Trace where GlobalConfiguration.DefaultServer.Configuration.VirtualPathRoot is consumed and compare the self-hosted and IIS-hosted values. Done means batch requests process without the virtualPathRoot ArgumentNullException in self-hosted mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.