13548 2
How to create XML document using XDocument in C#?

Hello, I need to add some data in XML file by programmatically creating it using C# and XDocument, so how I will create it?

For example, Suppose if I need output like below in XML

...
Type
Question
9274 2
The UPDATE statement conflicted with the FOREIGN KEY constraint

When I am trying to save Updated data in table using Entity Framework in ASP.NET MVC, I am getting the below error

...
Type
Question
2554 2
How to redirect from http to https in ASP.NET Core?

Hello, I would like to know, how can force user to redirect from http(not secured) page to https(secured page) in asp.net core?

I am using asp.net core boilerplate template.

...
Type
Question
10668 2
Invalid length for a Base-64 char array or string error in C#

When I am trying to decrypt the encrypted string using C#, I am getting an error as below

Invalid-length-for-a-Base-64-char-array-or-string-decryption-c-sharp.png

Here is the HTML Razor anchor link code clicking on which, I am trying to decrypt it

...
Type
Question
9894 3
How to convert dynamic JSON string into C# class?

Hello, I am not able to convert dynamic JSON response string into C# class object, it's a long JSON and i even tried to convert JSON into class using the  website http://json2csharp.com/ but it's doesn't provide me proper JSON class, Here is my sample JSON

...
Type
Question


7507 3
Getting error "Sequence contains no elements"

Hello, I am using the below code to fetch some data from database and getting the error "Sequence contains no elements"

 public static IEnumerable<CompanyLicenseKey> GetCompanyLicenseKey()
{
            OPEntities onepassDB = new OPEntities();

            //Let's get the onepass User model first
            var user = onepassDB.UserAccounts.Where(x => x.Email == OnePassUserAccountEmail).First(); //error in this line

            var userLicenseList = from c in user.CompanyProfiles
                                  join l in onepassDB.CompanyLicenseKeys.Where(x => x.IsDisabled == false)
                                  .Select(x => new { x.CRMID, x.LicenseKey, x.FriendlyName, x.ProductName })
                                  on new { c.CRMID } equals new { l.CRMID }
                                  select new Models.OnePass.CompanyLicenseKey { LicenseKey = l.LicenseKey, FriendlyName = l.FriendlyName, ProductName = l.ProductName };

            if (ProductName == "")
                return userLicenseList.ToList().OrderBy(x => x.FriendlyName);
            else
                return userLicenseList.Where(x => x.ProductName == ProductName).ToList().OrderBy(x => x.FriendlyName);
        }

Error image

...

Type
Question
9705 2
how to convert httppostedfilebase to httppostedfile in C#?

How do I convert httppostedfilebase to httppostedfile in C#? Here is my demo code sinppet:

...
Type
Question
12574 5
Count and Group by multiple columns in a foreach statement in C#

Hello,

I need to write a foreach statement (I don't have it yet) in which to group by and count the departments.

This is what I have done so far. How can I take the count of each column?

thank you

...
Type
Question
2431 2
How can I Enumerate an enum in C#?

How can I Enumerate an enum in C#? Here is my current code, and it does not works:

...
Type
Question
6298 3
How to insert C# variable value in between string properly?

Hello, I am trying to pass this string from back-end C# to front end, and want to render it as HTML, when passing this string to the front-end, it doesn't look proper, here is my current C# code.

...
Type
Question

Page 19 of 24