Tag Archives: MVC5

Unable to Access RDS Database from Elastic Beanstalk Application

Hey everyone,

I ran into a bit of an issue today where I was unable to access my RDS SQL Express instance from my .NET Elastic Beanstalk instance. I was receiving the following error:

1
The server was not found or was not accessible.

The solution turned out to be fairly simply thanks to this StackOverflow post: http://stackoverflow.com/a/33207022/522859

Get your server instance security group:
– Log into AWS
– Navigate to elastic beanstalk
– Open your application instance
– Open configuration
– Open instances
– Find “server” on the page and copy the value in the “EC2 security groups” field

Add your server instance security group to your rds rules:
– Navigate to the RDS Dashboard
– Open your RDS instance
– Click on view details (left hand side or top)
– Find Security and Network
– Click on the rds-launch-wizard under security groups
– Click on inbound rules (very bottom currently)
– Add a new inbound rule with the copied security group as the source

Could not find part of the path ‘C:\x\lib’ – Adding new Web API Project

Hey everyone,

I ran into the following error when I tried to add a new Web API project in Visual Studio Express 2015 for Web:

Could not find part of the path ‘C:\x\lib’

The workaround for this was to temporarily unbind the project from TFS: File > Source Control > Advanced > Change Source Control > Click unbind on each of the projects

While not the same problem, this post helped me out: https://github.com/NuGet/Home/issues/1164

Culture Info Codes

Hey everyone,

Just posting a link to this list of culture info codes etc. I was looking for the en-AU one but had a bit of trouble tracking it down.

Language Culture Name Display Name Culture Code ISO 639x Value
af-ZA Afrikaans – South Africa 0x0436 AFK
sq-AL Albanian – Albania 0x041C SQI
ar-DZ Arabic – Algeria 0x1401 ARG
ar-BH Arabic – Bahrain 0x3C01 ARH
ar-EG Arabic – Egypt 0x0C01 ARE
ar-IQ Arabic – Iraq 0x0801 ARI
ar-JO Arabic – Jordan 0x2C01 ARJ
ar-KW Arabic – Kuwait 0x3401 ARK
ar-LB Arabic – Lebanon 0x3001 ARB
ar-LY Arabic – Libya 0x1001 ARL
ar-MA Arabic – Morocco 0x1801 ARM
ar-OM Arabic – Oman 0x2001 ARO
ar-QA Arabic – Qatar 0x4001 ARQ
ar-SA Arabic – Saudi Arabia 0x0401 ARA
ar-SY Arabic – Syria 0x2801 ARS
ar-TN Arabic – Tunisia 0x1C01 ART
ar-AE Arabic – United Arab Emirates 0x3801 ARU
ar-YE Arabic – Yemen 0x2401 ARY
hy-AM Armenian – Armenia 0x042B  
Cy-az-AZ Azeri (Cyrillic) – Azerbaijan 0x082C  
Lt-az-AZ Azeri (Latin) – Azerbaijan 0x042C  
eu-ES Basque – Basque 0x042D EUQ
be-BY Belarusian – Belarus 0x0423 BEL
bg-BG Bulgarian – Bulgaria 0x0402 BGR
ca-ES Catalan – Catalan 0x0403 CAT
zh-CN Chinese – China 0x0804 CHS
zh-HK Chinese – Hong Kong SAR 0x0C04 ZHH
zh-MO Chinese – Macau SAR 0x1404  
zh-SG Chinese – Singapore 0x1004 ZHI
zh-TW Chinese – Taiwan 0x0404 CHT
zh-CHS Chinese (Simplified) 0x0004  
zh-CHT Chinese (Traditional) 0x7C04  
hr-HR Croatian – Croatia 0x041A HRV
cs-CZ Czech – Czech Republic 0x0405 CSY
da-DK Danish – Denmark 0x0406 DAN
div-MV Dhivehi – Maldives 0x0465  
nl-BE Dutch – Belgium 0x0813 NLB
nl-NL Dutch – The Netherlands 0x0413  
en-AU English – Australia 0x0C09 ENA
en-BZ English – Belize 0x2809 ENL
en-CA English – Canada 0x1009 ENC
en-CB English – Caribbean 0x2409  
en-IE English – Ireland 0x1809 ENI
en-JM English – Jamaica 0x2009 ENJ
en-NZ English – New Zealand 0x1409 ENZ
en-PH English – Philippines 0x3409  
en-ZA English – South Africa 0x1C09 ENS
en-TT English – Trinidad and Tobago 0x2C09 ENT
en-GB English – United Kingdom 0x0809 ENG
en-US English – United States 0x0409 ENU
en-ZW English – Zimbabwe 0x3009  
et-EE Estonian – Estonia 0x0425 ETI
fo-FO Faroese – Faroe Islands 0x0438 FOS
fa-IR Farsi – Iran 0x0429 FAR
fi-FI Finnish – Finland 0x040B FIN
fr-BE French – Belgium 0x080C FRB
fr-CA French – Canada 0x0C0C FRC
fr-FR French – France 0x040C  
fr-LU French – Luxembourg 0x140C FRL
fr-MC French – Monaco 0x180C  
fr-CH French – Switzerland 0x100C FRS
gl-ES Galician – Galician 0x0456  
ka-GE Georgian – Georgia 0x0437  
de-AT German – Austria 0x0C07 DEA
de-DE German – Germany 0x0407  
de-LI German – Liechtenstein 0x1407 DEC
de-LU German – Luxembourg 0x1007 DEL
de-CH German – Switzerland 0x0807 DES
el-GR Greek – Greece 0x0408 ELL
gu-IN Gujarati – India 0x0447  
he-IL Hebrew – Israel 0x040D HEB
hi-IN Hindi – India 0x0439 HIN
hu-HU Hungarian – Hungary 0x040E HUN
is-IS Icelandic – Iceland 0x040F ISL
id-ID Indonesian – Indonesia 0x0421  
it-IT Italian – Italy 0x0410  
it-CH Italian – Switzerland 0x0810 ITS
ja-JP Japanese – Japan 0x0411 JPN
kn-IN Kannada – India 0x044B  
kk-KZ Kazakh – Kazakhstan 0x043F  
kok-IN Konkani – India 0x0457  
ko-KR Korean – Korea 0x0412 KOR
ky-KZ Kyrgyz – Kazakhstan 0x0440  
lv-LV Latvian – Latvia 0x0426 LVI
lt-LT Lithuanian – Lithuania 0x0427 LTH
mk-MK Macedonian (FYROM) 0x042F MKD
ms-BN Malay – Brunei 0x083E  
ms-MY Malay – Malaysia 0x043E  
mr-IN Marathi – India 0x044E  
mn-MN Mongolian – Mongolia 0x0450  
nb-NO Norwegian (BokmÃ¥l) – Norway 0x0414  
nn-NO Norwegian (Nynorsk) – Norway 0x0814  
pl-PL Polish – Poland 0x0415 PLK
pt-BR Portuguese – Brazil 0x0416 PTB
pt-PT Portuguese – Portugal 0x0816  
pa-IN Punjabi – India 0x0446  
ro-RO Romanian – Romania 0x0418 ROM
ru-RU Russian – Russia 0x0419 RUS
sa-IN Sanskrit – India 0x044F  
Cy-sr-SP Serbian (Cyrillic) – Serbia 0x0C1A  
Lt-sr-SP Serbian (Latin) – Serbia 0x081A  
sk-SK Slovak – Slovakia 0x041B SKY
sl-SI Slovenian – Slovenia 0x0424 SLV
es-AR Spanish – Argentina 0x2C0A ESS
es-BO Spanish – Bolivia 0x400A ESB
es-CL Spanish – Chile 0x340A ESL
es-CO Spanish – Colombia 0x240A ESO
es-CR Spanish – Costa Rica 0x140A ESC
es-DO Spanish – Dominican Republic 0x1C0A ESD
es-EC Spanish – Ecuador 0x300A ESF
es-SV Spanish – El Salvador 0x440A ESE
es-GT Spanish – Guatemala 0x100A ESG
es-HN Spanish – Honduras 0x480A ESH
es-MX Spanish – Mexico 0x080A ESM
es-NI Spanish – Nicaragua 0x4C0A ESI
es-PA Spanish – Panama 0x180A ESA
es-PY Spanish – Paraguay 0x3C0A ESZ
es-PE Spanish – Peru 0x280A ESR
es-PR Spanish – Puerto Rico 0x500A ES
es-ES Spanish – Spain 0x0C0A  
es-UY Spanish – Uruguay 0x380A ESY
es-VE Spanish – Venezuela 0x200A ESV
sw-KE Swahili – Kenya 0x0441  
sv-FI Swedish – Finland 0x081D SVF
sv-SE Swedish – Sweden 0x041D  
syr-SY Syriac – Syria 0x045A  
ta-IN Tamil – India 0x0449  
tt-RU Tatar – Russia 0x0444  
te-IN Telugu – India 0x044A  
th-TH Thai – Thailand 0x041E THA
tr-TR Turkish – Turkey 0x041F TRK
uk-UA Ukrainian – Ukraine 0x0422 UKR
ur-PK Urdu – Pakistan 0x0420 URD
Cy-uz-UZ Uzbek (Cyrillic) – Uzbekistan 0x0843  
Lt-uz-UZ Uzbek (Latin) – Uzbekistan 0x0443  
vi-VN Vietnamese – Vietnam 0x042A VIT

Source: https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(vs.71).aspx

Cannot parse *.config file – AdaptivePayments SDK (PayPal)

Hey everyone,

Just working on a small project that uses PayPal’s C# AdaptivePayments SDK. I hit an error while attempting to make the following payment:

var service = new AdaptivePaymentsService();
payResponse = service.Pay(payRequest);
“Cannot parse *.config file. Ensure you have configured the ‘paypal’ section correctly.”

at PayPal.Manager.ConfigManager..ctor()
at PayPal.Manager.ConfigManager.get_Instance()
at PayPal.BasePayPalService..ctor()
at PayPal.AdaptivePayments.AdaptivePaymentsService..ctor()

It turns out that you need to add the following entries to your Web.config:

<!-- Under configuration > configSections. Add the following entry -->
<section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK" requirePermission="false"></section>
 
<!-- Under configuration. Add the following entry and modify to suit your app -->
<paypal>    
    <settings>
      <add name="endpoint" value="https://svcs.sandbox.paypal.com/"/>
      <add name="AdaptivePayments" value="https://svcs.sandbox.paypal.com/"/>
      <add name="connectionTimeout" value="360000"/>
      <add name="requestRetries" value="3"/>
      <add name="IPAddress" value="127.0.0.1"/><!-- May need to change this depending on your configuration -->
    </settings>
    <accounts>
      <account apiUsername="xxx" apiPassword="xxx" apiSignature="xxx" applicationId="APP-80W284485P519543T"/>
    </accounts>
  </paypal>

To get the account information you’ll need to do the following:
– Go to developer.paypal.com
– Login to your sandbox account
– Go to the dashboard
– Select accounts (from the list of all your sandbox accounts)
– Create a new one or select an existing business account
– Click profile
– Click API Credentials

Note that the steps required to get this configuration seem to change all the time. Hopefully this will be enough to get you on the right track.

TF30063: You are not authorized to access asxproject – TFS Online/Visual Studio

Hey everyone,

I ran into the following issue while trying to install the HTML Agility Pack via Nuget today:

TF30063: You are not authorized to access asxproject…

This fixed it for me:
– Go to “Team Explorer”
– Up the very top click on the “Connect to Team Projects” button (power cable looking icon next to the home button)
– Right click on the project and then click connect

Once connected, everything seemed to start working for me again. Check out this stackoverflow post more info: http://stackoverflow.com/a/16700451/522859

The installer has encountered an unexpected error installing this package.This may indicate a problem with this package.The error code is 29506 – SQL Server Management Studio

Hey everyone,

I ran into the following error while trying to install Sql Server Management Studio on Windows 8:

The installer has encountered an unexpected error installing this package.This may indicate a problem with this package.The error code is 29506

To fix it, all you need to do is run the exe with administrative privileges.

No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’ – MVC5

Hey everyone,

Just an error I came across while trying to use a new solution project:

No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’

The fix for this was simply to run the following command in the package manager console:

1
PM> Install-Package EntityFramework

Thanks to StackOverflow for the details: http://stackoverflow.com/a/18642452/522859

Change Default MVC5 Password Complexity Requirements – Passwords must have at least one non letter or digit character. Passwords must have at least one digit (‘0’-‘9’). Passwords must have at least one uppercase (‘A’-‘Z’)

Hey everyone,

I’ve started on a new MVC5 project and came across the following error message while trying to register a new user:

Passwords must have at least one non letter or digit character.
Passwords must have at least one digit (‘0’-‘9’).
Passwords must have at least one uppercase (‘A’-‘Z’)

While having a secure password is obviously important, I felt that most users would probably find these requirements a little extreme. After a bit of Googling I came across a StackOverflow post that mentioned a config class that you can use to edit these settings:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// App_Start > IdentityConfig.cs
 
...
 
// Configure validation logic for usernames
            manager.UserValidator = new UserValidator<ApplicationUser>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail = true
            };
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit = true,
                RequireLowercase = true,
                RequireUppercase = true,
            };
 
...

View Generated SQL in Entity Framework (EF)

Hey everyone,

Just a quick post on how to view the generated sql in entity framework. To start with, just add the following line to your db context constructor:

public class TestDbContext : DbContext
    {
        public TestDbContext() : base("name=TestDbContext")
        {
            this.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); //This line
        }
        ...

With this line added, you should now be able to see all of your generated sql in the output window.

SELECT TOP (1) 
    [Project1].[VidId] AS [VidId], 
    [Project1].[CreatedAt] AS [CreatedAt], 
    [Project1].[CHECK] AS [CHECK], 
    [Project1].[SourceCheck] AS [SourceCheck]
    FROM ( SELECT 
        [Extent1].[VidId] AS [VidId], 
        [Extent1].[CreatedAt] AS [CreatedAt], 
        [Extent1].[CHECK] AS [CHECK], 
        [Extent1].[SourceCheck] AS [SourceCheck]
        FROM [dbo].[Vids] AS [Extent1]
        WHERE [Extent1].[VidId] < @p__linq__0
    )  AS [Project1]
    ORDER BY [Project1].[VidId] DESC
 
-- p__linq__0: '535' (Type = Int32)
-- Executing at 28/06/2014 5:00:16 PM +10:00
-- Completed in 0 ms with result: SqlDataReader

If you’re not using EF6, there were a few other options where I came across this solution: http://stackoverflow.com/a/20751723/522859

Duplicate type name within an assembly. – Entity FrameWork (EF)

Hey everyone,

I ran into this error message while trying to debug a project today:

“Duplicate type name within an assembly.”

 

The workaround to this was actually pretty weird. Remove all of your breakpoints that appear before this exception and place one after it instead. That’s it!

A bit of a weird issue, but according to the StackOverflow post where I found the solution Microsoft are aware of it: http://stackoverflow.com/a/23529882/522859