Appetere

3

votes
1

answer
1.7k

views

WebAPI route with period in final parameter fails

The Problem Using WebAPI where the final parameter in a request includes a period / full-stop / '.' For a 'simple' route like /api/values/dog.cat this is routed ok. For a more complex route like /api/values/mammal/dog.cat this returns 404 My questionis how can I get the more complex route to work? B...
Appetere
4

votes
1

answer
721

views

Eager load Records in Orchard CMS

I'm building an Orchard CMS module, where I want to eager load data, but can't work out how to do this. For example a Client has many Events, so I have a ClientRecord & EventRecord for these: public class ClientRecord { private IList _eventRecords; public virtual int Id { get; set; } public virtual...
Appetere
6

votes
3

answer
2.1k

views

Using the Command-Query Separation principle in MVC Controllers

I like the idea of Command Query Separation but can't see how to use it within an MVC Controller action which is adding an entity, and needs the new entity's ID after adding it. For example, in the simplified example below a service is used to create a new item: public ActionResult Assign(AssignView...
Appetere
11

votes
5

answer
9.7k

views

Building an OrderBy Lambda expression based on child entity's property

I'm trying to generate a LINQ OrderBy clause using lambda expressions with an input of the column name of an entity as a string (in the 'sortOn' variable below). The code below works fine for a sortOn value like 'Code' generating the lambda p => p.Code But I would also like to sort on a child entit...
Appetere
2

votes
1

answer
1.9k

views

Saving and autosaving PowerPoint OpenXML PresentationDocuments

I'm looking for some advice about saving OpenXML documents, specifically a PresentationDocument. In my scenario I open a PowerPoint .pptx presentation directly from disk, that acts as a template. I then add (copy) slides from various other PowerPoint presentations. For each separate source present...
Appetere
4

votes
2

answer
2.6k

views

resolve all given the Type

From the Autofac documentation I can see how to get all registrations for a class T: public T[] ResolveAll() { return _container.Resolve().ToArray(); } But when I only have the Type available, how can I get the equivalent results? public Array ResolveAll(Type service) { return _container.Resolve( ??...
Appetere
2

votes
2

answer
917

views

Failure of Castle Winsor 3.0 NuGet installation

I'm trying to install Castle Windsor 3.0 using NuGet, and it fails with the following message: PM> Install-Package Castle.Windsor 'Castle.Core (≥ 3.0.0)' not installed. Attempting to retrieve dependency from source... Done. Install-Package : Id is required. Version is required. Authors is required...
Appetere
2

votes
2

answer
33

views

What do git manual sections mean?

The git manual uses page titles like 'git-commit(1)' or 'git-add(1)' when the commands being discussed are 'git commit' or 'git add'. What does the '(1)' mean in all these titles??
Appetere
2

votes
1

answer
1.3k

views

Map required field to nullable in database

I have an Entity Framework code-first model in which a Supplier must always have a SupplierGroup: public virtual SupplierGroup SupplierGroup { get; set; } public int SupplierGroupId { get; set; } But the underlying database has to have SupplierGroupId as nullable (due to another system using it, in...
Appetere
2

votes
1

answer
2.6k

views

IIS logs 200 status but returns 500 status

I'm trying to diagnose an issue where IIS7.5 shows a successful (200) response in the IIS logs, but a 'Service temporarily unavailable' HTML message is returned to the browser with a 500 status, after 30 seconds. Some more details: I'm calling a WebAPI endpoint to run an import function that involve...
Appetere
7

votes
3

answer
3.2k

views

Creating OpenXML documents using JavaScript

I have an application that needs to create simple OpenXML documents (in particular PowerPoint presentations) using JavaScript. Can anyone suggest how to get started on this please (or even if it is possible)? I've used the Microsoft OpenXML SDK for doing something similar using C#, and was wonderin...
Appetere
4

votes
1

answer
1.6k

views

Getting JSON from TeamCity API with CORS

I am trying to use the TeamCity API to retrieve build data in JSON format to show in a real-time display. The display is a simple JavaScript application, served up as a web-page on a different domain to the TeamCity server. Therefore this has to be handled as a cross origin request (CORS). My probl...
Appetere
6

votes
1

answer
2.4k

views

How to mock context while unit testing code using VirtualPathUtility.GetAbsolute method

I am running unit tests on code which uses VirtualParthUtility.GetAbsolute, but am having problems mocking the context for this to work. I've set up a mock context with Moq as follows private Mock MakeMockHttpContext(string url) // url = '~/' { var mockHttpContext = new Mock(); // Mock the request v...
Appetere
14

votes
2

answer
3.3k

views

Added code-first entity doesn't lazy-load properties

I have a problem where a property of a newly added entity is not lazy-loaded, if required immediately after adding the entity. For example: I have a User entity with a virtual JobRole property: public class User { public int Id { get; set; } public virtual JobRole JobRole { get; set; } public int J...
Appetere
4

votes
1

answer
1.8k

views

Using Ninject with Udi Dahan's Domain Events

I'm using Ninject in an MVC project and am trying to implement Domain Events following Udi Dahan's pattern http://www.udidahan.com/2009/06/14/domain-events-salvation/ In the extract below, the 'Container' is used to resolve all the event-handlers for the particular type of event that has been raised...
Appetere
8

votes
1

answer
2.9k

views

Does Role Provider cache per request?

My MVC application makes use of a User's Role in multiple places during individual page requests. My question is whether the default SqlRoleProvider caches the current User's Roles for the lifetime of a page-request? For example, I make use of Roles in attributes on Controller methods: [Authorize(R...
Appetere
8

votes
3

answer
5.6k

views

Where to run a duplicate check for an entity

I'm looking for advice on the 'best' place to put validation logic, such as a duplicate check for an entity, when using Entity Framework Code-First, in an MVC application. To use a simple example: public class JobRole { public int Id { get; set; } public string Name { get; set; } } The rule...
Appetere
3

votes
0

answer
721

views

Owin pipeline branches run all middleware at first stage-marker encountered

When creating an (unbranched) OWIN pipeline, stage-markers are respected. But when using a branched pipeline (with app.Map or app.MapWhen) all middleware in each branch runs at the stage of the first stage-marker encountered. Is there any way to use stage-markers within a branch? To illustrate the p...
Appetere
3

votes
1

answer
270

views

Specify options with git commands via LibGit2Sharp

Is it possible to replicate git commands that use options using LibGit2Sharp? For example I want to use commands like (but not limited to): git fetch --all -p [fetch all remotes and prune any branches which don't exist] git merge --ff-only origin/master [fast-forward merges only] git merge IssueXyz...
Appetere
63

votes
7

answer
23.9k

views

What is intent of ID Token expiry time in OpenID Connect?

In OpenID Connect an access token has an expiry time. For authorization code flow, this is typically short (eg 20 minutes) after which you use the refresh token to request a new access token. The ID token also has an expiry time. My question is what is the intent of this? Any ID token expiry time...
Appetere
61

votes
2

answer
27.7k

views

Using bearer tokens and cookie authentication together

I have a single page app - more or less based on the MVC5 SPA template - using bearer tokens for authentication. The site also has a couple of conventional MVC pages which need to be secured, but using cookie authentication. In Startup.Auth I can enable both types of authorisation: app.UseCookieAuth...
Appetere