Practical .NET, software, and AI tutorials by Gerard Beckerleg, a developer in Sydney.
- Web Api 2, OWIN and StructureMap
Add the following code to your startup file: public class Startup { public void Configuration(IAppBuilder app) { // setup http configuration GlobalConfiguration.Configure(config => { //configure dependency injection var container = IoC.Initialize(); config.ConfigureDependencyInjection(container); config.ConfigureControllerSelector(); } } } And create the following IoC container: public static class IoC { public static IContainer Initialize() { var container = new Container(c => { c.AddRegistry(); // TODO: Add custom registry here }); return container; } } And a WebApi Registry:
- IDX10708: 'System.IdentityModel.Tokens.JwtSecurityTokenHandler' cannot read this string: 'Bearer'.
Today I got the following message when trying to send the rawData of a JwtSecurityToken I had created manually: IDX10708: ‘System.IdentityModel.Tokens.JwtSecurityTokenHandler’ cannot read this string: ‘Bearer’. The problem was that the rawData portion of the JwtSecurityToken is not populated until the token has been validated. I ended up using the following solution to create and validate JWT Tokens.
- Nuget Push failed to process request System.Net.HttpWebRequest.GetResponse()
When trying to push a NuGet package to our new local NuGet repository we recieved the following error: System.InvalidOperationException: Failed to process request. ‘Internal Server Er ror’. The remote server returned an error: (500) Internal Server Error.. —> System.N et.WebException: The remote server returned an error: (500) Internal Server Erro r. at System.Net.HttpWebRequest.GetResponse() at NuGet.RequestHelper.GetResponse(Func`1 createRequest, Action`1 prepareRequ est, IProxyCache proxyCache, ICredentialCache credentialCache, ICredentialProvid er credentialProvider) at NuGet.HttpClient.GetResponse() at NuGet.PackageServer.EnsureSuccessfulResponse(HttpClient client, Nullable`1 expectedStatusCode) — End of inner exception stack trace — at NuGet.PackageServer.EnsureSuccessfulResponse(HttpClient client, Nullable`1 expectedStatusCode) at NuGet.PackageServer.PushPackageToServer(String apiKey, Func`1 packageStrea mFactory, Int32 timeout) at NuGet.PackageServer.PushPackage(String apiKey, IPackage package, Int32 tim eout) at NuGet.Commands.PushCommand.PushPackageCore(String source, String apiKey, P ackageServer packageServer, String packageToPush, TimeSpan timeout) at NuGet.Commands.PushCommand.PushPackage(String packagePath, String source, String apiKey, TimeSpan timeout) at NuGet.Commands.PushCommand.ExecuteCommand() at NuGet.Commands.Command.Execute() at NuGet.Program.Main(String args)
- ADFS 3.0 WIF .NET 4.5 Cheat Sheet
After wrestling with ADFS 3.0 and WIF in .NET 4.5 I decided to create this cheat sheet to map the numerous mixed terms that exist between ADFS and WIF. ADFS Authentication Authorization Example Notes Identifier Wtrealm Audience urn:servername This can be anything as long as it is unique and it not used anywhere else Relying Party Endpoints Wreply https://localhost/testserver/ This is the address of the server that wants to use ADFS for identity. Ensure you add the trailing / in Wreply this is a bug in WIF Service Endpoint MetadataAddress https://adfsserver/federationmetadata/2007-06/federationmetadata.xml Contains the details that WIF will use to configure authentication. Without this file you would have to configure the server manually Service Endpoint Issuer http://adfsserver/adfs/services/trust
- SharePoint 2013 Error occurred in deployment step 'Activate Features': Column 'WSPublishState' does not exist. It may have been deleted by another user.
After following this tutorial on How to Create Custom SharePoint Server 2013 Workflow Forms with Visual Studio 2012 Sand-boxed Solutions I received the following error: Error occurred in deployment step ‘Activate Features’: Column ‘WSPublishState’ does not exist. It may have been deleted by another user.
- Error occurred in deployment step 'Install app for SharePoint': There is no Workflow App Part registered.
When trying to deploy a SharePoint hosted custom workflow I received the following error: Error occurred in deployment step ‘Install app for SharePoint’: There is no Workflow App Part registered. The problem was that the SharePoint 2013 server did not have the WorkFlow Manager installed and configured.
- Disabling Roslyn Compiler Preview Not Working
After installing the Roslyn preview we found that when switching back to the standard compiler by going to tools | extensions and updates | Roslyn Preview | Disable was being ignored. In order for disable to work properly you need to delete the following target files created by the Roslyn Preview:
- How Spotify Builds Products
I saw a great video the other day explaining the working culture at Spoitfy and later that day on Twitter I saw a nice image showing how they they build products and it really resonated with me and the message we were trying to get across in this video. I feel this is a great image to use with customers to help explain what I think is the best way to approach building a new product. I think it might also be better than my previous favourite the Agile Mona Lisa. Update - part 2 has just been released
- Invalid token '=' in class, struct, or interface member declaration { get; } =
If you are getting errors like: Invalid token ‘=’ in class, struct, or interface member declaration when you compile your code in Visual Studio and the class looks something like: public class Point(int x, int y) { public int X { get; } = x; public int Y { get; } = y; } then you will need to install the new Roslyn compiler from Microsoft. The error you are getting is because the new compiler has many new language features that are not compatible with the previous compiler. The above code is an example of the new Primary Constructors feature
- Visual Studio warning: “Some of the properties associated with the solution could not be read”
Today I received the message: One or more projects in the solution were not loaded correctly. Please see the Output Window for details when opening a solution in Visual Studio. Unfortunatley the details in the output window were not very helpful: