Questions tagged as 'c#'

1
answer

How to find out the file extension through the Bytes array?

I wonder if it is possible to give a get in the file extension through the Bytes Array. Well, I downloaded a file from the server, and it can be either .JPEG or .EPS, but I'm not able to know what file I got and I can not set the MIME / Extensio...
asked by 26.12.2017 / 17:30
1
answer

Is it a bad practice to use an "optional" variable within an object?

When I download a photo on my system, the download process passes through a security method that returns an object called DownloadResponse . public class DownloadResponse{ public bool IsValid{get; set; } public int DownloadTypeID...
asked by 16.10.2017 / 15:41
1
answer

Call an asynchronous function in an ActionResult?

How to call an asynchronous function on a non-asynchronous controller, to be clearer follows a situation: I have a form that when saving it needs to save data in the database and simultaneously send an email notifying a user that such action...
asked by 04.03.2016 / 13:37
1
answer

Exhaust characters

I'm having trouble understanding the escape characters, I already know that the \n line breaks in a string, but the other characters I can not understand. Ex: \a \b \f \r \t \v , I joined the site link and does not have man...
asked by 04.03.2016 / 04:44
2
answers

Multiple projects in MVC and WebAPI

I'm looking for a project template that involves multiple MVC and WebAPI projects. In the solution I'm thinking of designing (if possible) a content management solution for multiple clients and I'm thinking this way: I wanted to have a Pai pr...
asked by 08.02.2016 / 21:45
1
answer

How to read all bytes of a file

I have a question in ReadBytes (int) My code looks like this: BinaryReader r = new BinaryReader (File.OpenRead(ARQUIVO)); byte[] arraybyte = r.ReadBytes(100000); This 100000 that I put is because I do not know the size of the f...
asked by 20.05.2015 / 17:33
1
answer

Razor C # make list and sublist with ListString (originally "how to check if an HTML element already exists")

I need to know if an HTML element already exists, in my loop, if it exists I use it, if it does not exist I'll create one. How would you do this within a @foreach (var item in Model){ ... } Following the comment of Gypsy, as it is not po...
asked by 13.05.2015 / 01:28
1
answer

Use of Time with EF 6

I have a class with the following property. public TimeSpan TempoIdeal { get; set; } Estou atribuindo esta propriedade com TempoIdeal = new TimeSpan(days: 3, hours: 15, minutes:10, seconds: 0); When trying to insert I g...
asked by 23.06.2016 / 05:39
1
answer

Permissions system in ASP.NET MVC

I have long developed a system in ASP.NET MVC, where I used the MvcSiteMapProvider package, based on it I made some modifications to the AuthorizeAttribute to perform the user permissions check. In my SiteMap I made some additions, which were...
asked by 08.07.2016 / 13:42
1
answer

Error saving field of type DateTime

I am setting up an example of Code First, but at the time of saving a field of type DateTime in the database I get the following error    Converting a datetime2 data type to a datetime data type   resulted in a value out of range. \ r \ nThe...
asked by 23.11.2016 / 19:58