Posts by perozzo • 2,653 points
101 posts
-
2
votes1
answer212
viewsQ: Add customizable SOAP Header
I’m consuming a web service SOAP which does not provide any information on Headers, nor of autenticação. I added the same in my project by the tool Add Connected Service in Visual Studio. Looking…
-
0
votes1
answer41
viewsA: Configure requestTimeout in code
According to Dmitry Pavlov at Stackoverflow.com: No, there is no way to do this as you described. But according to the documentation, you can just add web.config to your project and specify this…
-
0
votes2
answers228
viewsA: Json Web Token - How to create a token that accesses only a particular Controller or Action?
To restrict a Controller with a JWT, that is, oblige access to it with only one Token, place the attribute Authorize on top of the Controller desired: [Authorize] [Route("[controller]")] public…
-
1
votes0
answers12
viewsQ: Removal of Event Handlers
In an application Xamarin.Android, it is important to remove the Event Handlers when leaving the screen to avoid memory consumption? It would be a good practice? For example, in the OnCreate() of…
-
0
votes1
answer18
viewsA: App service with the same name in Azure
Yes, you can do. Maybe the Azure may take a while to identify that the application no longer exists and still show an error saying that the name is already being used. Refresh the page and wait a…
-
1
votes3
answers1286
viewsA: Which is faster: NULL or NOT NULL (with an empty string)?
The difference is that a field NULL can be null, ie it is not required to have any value. And a field NOT NULL needs some value in the column, be a string.Empty or a "". I believe if you have a…
-
3
votes2
answers112
viewsA: How to add a built-in view to an Asp.net core 2.0 controller
Your View must be inside a folder with the same name as the Controller (but without the Controller. Let’s say your Controller be called CompanyController, the name of the folder View that Controller…
-
0
votes1
answer44
viewsA: Problem in the XAML Textbox for XAML.Cs
Maybe I declared the components wrong. Below follows the correct way to name your components, using the property x:Name: <TextBox x:Name="txtCpf" HorizontalAlignment="Left" Height="23"…
-
3
votes1
answer164
viewsA: Xamarin.Android App with Bing Maps
After a quick exchange of information with Matheus (author of the question), I realized that there is no explicit need for the use of Bing Maps. Then I will present two map Apis to Xamarin.Android…
-
1
votes1
answer36
viewsA: Is there a need for ". this" in an Android Xamarin project?
No need to use the .this at the end of the class. Either you use the class name or just the this. Below is an example of how the correct way to start a Activity passing "parameters" to it. var…
-
6
votes1
answer671
viewsA: ASP.NET CORE Dependency Injection
I will show how I use in my project which is also done through the Repository Pattern and works perfectly. Startup.Cs Within the class Startup.cs create a property of type IConfigurationRoot, if…
-
1
votes4
answers2332
viewsA: Regex to pick word between two words or "/"
You can try something like: var caminho = "/9c2a1079-35f0-4298-9eb3-7f63903f2ae1/resourceGroups/perarEssaPalavra/providers/"; var separado = path.split('/'); var palavra =…
-
2
votes1
answer73
viewsA: Consuming a Web Service Asp . Net Xamarin application
I believe the problem may be in the way you’re creating your HttpClient. You can try it this way: public async Task GetLista() { try { aguarde = true; HttpClient cliente = new HttpClient();…
-
3
votes1
answer94
viewsA: Fetch content from an online file
First, I recommend using a well-defined text/file structure to save your information, such as JSON. This will make the handling of your data simpler and more practical to handle. JSON is basically a…
-
2
votes1
answer127
viewsA: How do you expect a bool to stay true?
I don’t know how the method called yours is implemented StartNewTest, but you can start this method in another thread: await Task.Factory.StartNew(async () => { await StartNewText(TestType); });…
-
1
votes1
answer146
viewsA: Doubt in an SQL query
Let’s start by analyzing your table diagram. Given your problem, just two tables of all the informed ones are important to find what you need. Notice that there is a table Cliente and a table…
-
0
votes4
answers1437
viewsA: Get user logged in to Asp.Net Core 2.0
Only complementing with an option that can be used only within one Controller. string currentUser = User.Identity.Name; It is also possible to check if the user is in particular Role:…
-
4
votes1
answer220
viewsA: How to declare and pass a decimal variable from XAML to C#?
To access the value of your Entry, you can do the following: <Entry x:Name="txtValue" Keyboard="Numeric"/> Note that I used the property x:Name to set a name for your Entry. By doing this, you…
-
2
votes2
answers133
viewsA: Remove from mvc page " 2017 - Project Name"
Typically in an ASP.NET MVC project, the default template generated by Visual Studio comes with some ready-made settings already. This is one of them. There is a "shared" file that is the Layout…
-
8
votes1
answer614
viewsA: Transform Image into byte?
You can try the following: // Carrega sua imagem e salva em um array de bytes byte[] imgdata = System.IO.File.ReadAllBytes(@"C:\Test\simba.jpg"); // Salva seu array de bytes em um arquivo…
-
1
votes2
answers65
viewsA: Problem with variable connection to C# Visual Studio Database
My suggestion would be to do the following. Declare your connection variable like this: string _conn; And in the event of index of your ComboBox, put the following code: private void…
-
2
votes1
answer55
views -
2
votes1
answer538
viewsA: overwrite certain line of the txt file
You can use something like: private void ChangeUser(string currentUser, string newUser, int position) { string sourceFile = @"C:\Test\root.txt"; string[] lines = File.ReadAllLines(sourceFile);…
-
0
votes1
answer727
viewsA: How to do for when click on the button perform action every 1 second
Instead of using a BackgroundWorker, you can use a Timer, library System.Timers.Timer. Your code can be done as follows: System.Timers.Timer _timer; public Form1() { InitializeComponent(); // Botão…
-
3
votes1
answer614
viewsA: How to close the program by pressing the button
Try it this way: public Home() { InitializeComponent(); this.KeyDown += Home_KeyDown; } private void Home_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) {…
-
1
votes1
answer129
viewsQ: Name of a Role with accent in the Identity database
The need to create a Role with emphasis on the table of Roles of Identity in the database: "Technical". My question is whether this can generate further problems, perhaps at the time of checking…
-
5
votes1
answer157
viewsQ: Error converting varchar to integer
By performing the following UPDATE through my API (.NET Core): UPDATE Aula SET WHATEVER = WHATEVER WHERE ID_AULA = @examID Code: string query = builder .AppendLine("UPDATE Aula") .AppendLine("SET…
-
4
votes2
answers99
viewsQ: Save the same file at the same time in different threads
In my software I have a thread that every second updates the X file. This same file can also be updated through a user action that will be in another thread (may be at any time). My question is:…
-
0
votes2
answers131
viewsA: Which component can I use as a table in c#?
Since you are searching data from the database, you can use an element called DataGridView. For more information on how to use it, follow some links: Link 1 Link 2…
-
4
votes1
answer330
viewsA: Web chart with c#
The options below are both free and easy to implement: Google Charts - Google Charts Rickshaw - Rickshaw Canvasjs - Canvasjs I put in order that me found it easier to work and implement. It can test…
-
3
votes1
answer46
viewsA: Date format c#
First, create an object DateTime with the desired date: DateTime date1 = DateTime.ParseExact("06/04/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture); Then convert to the desired format: string…
-
2
votes2
answers472
viewsA: How to make a Textbox accept only the letters S and N?
In the archive .xaml of his Window put the following code. What matters here is the event KeyDown="txtTest_KeyDown": <TextBox x:Name="txtTest" KeyDown="txtTest_KeyDown" HorizontalAlignment="Left"…
-
0
votes1
answer376
viewsA: C# how to send an email containing a hyperlink using System.Net.Mail?
Place the link as follows: <a href=\"http://www.MEUSISTEMA.com/ResetPassword?RecoverCode=893P7IN83FXO5UO2WASHTQI65LCP792O\">Clique aqui para redefinir sua senha.</a> Notice the counter…
-
2
votes1
answer1841
viewsA: Deserialize List JSON C#
One of the ways that can be done is this. Create a class that will serve as your model json. This model is based on json that you get on the GET you mentioned. using Newtonsoft.Json; public class…
-
2
votes1
answer834
views -
8
votes3
answers2496
viewsA: How do I find the C# version I’m using?
It is possible to verify the version through code as well: string version = typeof(string).Assembly.ImageRuntimeVersion; However, from what I was analyzing, the version informed by…
-
3
votes1
answer101
viewsQ: Is ASMX web service obsolete?
I came across the need to consume an ASMX Web Service. Until then I had only consumed Restful Apis. I noticed that the same is very different from a Restful API, for example. Given the way it is…
-
0
votes1
answer1191
viewsA: Mask with ASP.NET Core MVC
You can clear the CNPJ field by removing the special characters before sending them to the database. To do this, create a method for them. Add the following method to your Controller: private string…
-
0
votes3
answers3627
viewsA: Format a string for phone format
You can use the following: string phone = "49988070405" string formatted = string.Format("{0:(##) #####-####}", phone);
-
4
votes2
answers1242
viewsA: get return from sql c#
Modify this part of your code: while (cmd.ExecuteReader().Read()) { retorno[0][contador] = cmd.ExecuteReader().ToString(); contador++; } To: SqlDataReader reader = cmd.ExecuteReader(); while…
-
1
votes1
answer165
viewsA: Visual Studio 2015 installation error
After researching a little I checked that the installer may have made a mistake when installing x86 and x64 libraries. There are some ways to solve the problem, I will quote two: first option 1.…
visual-studio-2015answered perozzo 2,653 -
2
votes2
answers55
viewsA: Problem saving data to database
Probably the error is happening due to a conversion that is returning an exception. More precisely on these lines: newChemical.MW = Decimal.Parse(MWField.Text); newChemical.VFId =…
-
1
votes3
answers870
viewsA: How to pass a value from one method to another method within the same class ? C#
There are a few ways to do this. I will present two: First solution: public void MostrarDespesas(float tot) { // Agora você tem acesso ao valor que está no tot, faça o que quiser com ele…
-
-1
votes3
answers1166
viewsA: How to access and stop a Thread? ASP.NET C#
You can use Thread.Abort. According to your code, thread.Abort();. But according to a post of Eric Lippert, it’s not certain that this will actually stop the Thread, not to mention that it is risky…
-
1
votes2
answers145
viewsA: How to run request again after having permission accepted on android?
private String _number; public void makeCall(String s) { _number = s; Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + s)); if…
-
0
votes1
answer1022
viewsA: Recover last inserted id and selected stroke
For this, you need to use the function OUTPUT INSERTED.ID and the method command.ExecuteScalar(). try { SqlConnection sqlConn = new SqlConnection(_connectionString); SqlCommand inserirAluno = new…
-
0
votes1
answer65
viewsA: Programming a button that when clicking for the second time, the form returns to the previous position
There are several ways to do this. Follow an example: The code below is a Form whole. I created the same only for testing. Remember to adapt the same with your code that already exists in your Form:…
-
0
votes1
answer140
viewsQ: Html2canvas ASP.NET Core
I am trying to add html2canvas to my ASP.NET Core web site. In the documentation, they say to use: npm install html2canvas When I execute this command, the html2canvas is installed in:…
-
1
votes1
answer30
viewsA: Android System Login Error (Maketoast)
When you’re inside a Thread other than UI Thread, you need to invoke the elements that will work with the UI in UI Thread. In these cases we use the method runOnUiThread. In your case, just call the…
-
1
votes2
answers156
viewsA: Problem adding C#images
You can use only one \, but for that, put a @ in front of the string: File.Exists(@"C:\Users\32-add.png") And you can also use two \, but without the @: File.Exists("C:\\Users\\32-add.png")…