Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
0
votes2
answers478
viewsA: Hybrid Web Application (MVC and Web API)
There is. The complexity is less, the Scaffoldings and the context of data may be the same, avoiding large rework. Separation shall occur only if one disrupts the functioning of the other, in cases…
-
0
votes1
answer275
viewsA: Import . csv file to server
There are some, like the jQuery File Upload. Here is an article that explains how to implement for ASP.NET MVC. Dropzone.js is another elegant solution with the same principle. A few more: Plupload;…
-
0
votes1
answer322
viewsA: Problem saving checkbox text value to my database
You can save the numbers of each day as one string: [HttpPost] [ValidateAntiForgeryToken] public ActionResult CriarGrupo([Bind(Include =…
-
2
votes1
answer100
viewsA: Aspnet MVC database first or code first
That’s the problem that’s wrong? No. Identity is designed to work with a nearly complete level of customization. Not only is it possible to define more User relationships with other entities, but…
-
1
votes1
answer32
viewsA: Javascript src link
How do I solve this problem? Not using this notation: "~/Images/delete_database.png"; It is only valid within the server code. Not in client code. Use instead: noDataIcon.src =…
-
3
votes2
answers63
viewsA: Is it possible to insert the character '#' (hash) in the MVC routes?
Is it possible to do this natively? Is there any way around the situation? Not. # is a symbol reserved for browsers to indicate anchors and cannot be part of routes. As only the customer has access…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
0
votes2
answers939
viewsA: How to get the value of an @Html.Textboxfor to an Input? Asp.net mvc
@Html.TextBoxFor() generates a new <input> for you. The correct thing is to take directly the value of the Model: <input class="form-control input-sm" autocomplete="off"…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
3
votes2
answers621
viewsA: Entityframework . Asenumerable() or . Tolist()?
What is the best approach in this case? Continue to use List<>, which is the resolution in memory of an enumeration. An enumeration may be a function or method whose performance is worse. If…
-
2
votes1
answer616
viewsA: Modify table Aspnetuserclaims Asp.net Identity
If you are using ASP.NET Identity, the correct one is your Usuario inherit from IdentityUser: public class Usuario : IdentityUser { ... } Table naming settings can be changed through the event…
-
1
votes1
answer39
viewsA: Is it possible to display more than 1 field information in @Html.Dropdownlistfor?
Thus: Controller ViewBag.TituloPos = tbuscar.ListarTodos(); View @Html.DropDownListFor(x => x.IDTITULOPOSS, ((IEnumerable<TituloPosAplicacao>)ViewBag.TituloPos).Select(tpa => new…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
2
votes1
answer31
viewsA: Doubt with Routes in Asp.net mvc
But in this Controller, if you have a new Action and you need a parameter, if you try to open this link, you will get an error. Is there any way to avoid this mistake? I don’t understand what you…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
1
votes2
answers179
viewsA: Entity Framework Template and Domain Class
..., wanted to know if it is correct to have an EF model class to represent the database data and one to represent the domain class. IS incorrect. Using two distinct classes, you bring to the…
entity-frameworkanswered Leonel Sanches da Silva 88,623 -
3
votes3
answers6679
viewsA: creating a python voting bot
Check the return of the request. To get it right, the status_code needs to be 200: response = requests.post(url, data=dados) print(response) print(response.status_code)…
pythonanswered Leonel Sanches da Silva 88,623 -
6
votes1
answer163
viewsA: JSP for developers . NET
JSP is more like ASP, ASP.NET or ASP.NET MVC? At first, for all three, although it is not exactly correct to establish this kind of parallel. JSP is an HTML processing technology, as well as ASP,…
-
4
votes1
answer2870
viewsA: Print a list of objects as string in Python
Define a method in your class __repr__(): class Expressao(object): def __init__(self, nivel, tipo, expressao, resposta): self.nivel = nivel self.tipo = tipo self.expressao = expressao self.resposta…
-
1
votes2
answers672
viewsA: How to pass a Ienumerable Model to a Controller?
The Binding is wrong. See the name of ids and of names. id="item_VALORAPOSTA1" name="item.VALORAPOSTA1" id="item_VALORAPOSTA2" name="item.VALORAPOSTA2" id="item_VALORAPOSTA3"…
-
6
votes1
answer1276
viewsA: Encrypt App.Config
Make sure that the . NET Framework is in your PATH (here put C:\Windows\Microsoft.NET\Framework\v4.0.30319 in the path); Open a Powershell or command prompt; Use the following command: >…
-
12
votes2
answers1277
viewsA: How to store a List<Object> in a database?
First you need to choose a database to work with. For C# there are several options, with Microsoft SQL Server the most complete option to work with C#. To persist your data, the recommended is to…
-
0
votes1
answer270
viewsA: How to remove Essentials Web extension from visual studio 2015?
I have never heard that Web Essentials disables Visual Studio commands. It must be something else. Try repairing the installation of Visual Studio. In Programs and Resources, find your Visual Studio…
-
4
votes2
answers817
viewsA: Check if string starts with number
Something like that? public static bool IsNumber(string str) { return new Regex(@"^[0-9]+").IsMatch(str); } I made a Fiddle.…
-
2
votes1
answer1204
viewsA: Query with parameter passing in a Url.Action
Thus: <a href="@Url.Action("SelecionarModalidade", "Modalidade", new { id = 1 })" class="btn btn-lg btn-block btn-warning glyphicon glyphicon-hand-left">
-
7
votes3
answers162
viewsA: Problems with SELECT with 2 Wheres
The correct way to do this is by using parameterization. This way, you can inject unwanted SQL code into your query: Cmm.CommandText = "SELECT CodAutomaticProd, DescProd, BrandCod FROM tbProdutos…
-
2
votes2
answers1083
viewsA: Fields in the same line MVC5 Application Bootstrap
In Bootstrap, keep in mind that all space is divisible by 12 or multiples of 12. When you do: <div class="form-group"> @Html.LabelFor(model => model.Nm_EquipeMinima, new { @class =…
-
6
votes1
answer839
viewsA: ASP.Net and C# - automatic e-mail sending
How can I do that? ASP.Net has something to that effect? Yes, the Hangfire. To schedule a task to run every day: RecurringJob.AddOrUpdate( () => MeuMetodoDeAtualizacao(), Cron.Daily); Hangfire…
-
1
votes1
answer105
viewsA: EF mapping for tables with variable name
In short, yes. At the event OnModelCreating from your context, define the following: protected override void OnModelCreating(DbModelBuilder modelBuilder) { ConfigurationRegistrar…
-
0
votes1
answer213
viewsA: Set up MVC route
Possibly if Controller must have the namespace of the first route: namespace Aperam.PCP.PNB.UI.Controllers.Cadastros { public class ConsultaUMController : Controller { ... } } Switch to: namespace…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
3
votes2
answers3574
viewsA: Abstract Python class, how to choose implementation
Abstract classes in Python are implemented using the module abc. The correct would be something like this (considering Python 3.4 and above): from abc import ABC, abstractmethod class…
-
1
votes2
answers245
viewsA: ignore in function call if empty
If I understand, something like this already resolves: if len(a) > 0 and len(b) > 0: funcao((a, b)) EDIT In fact you also need to check if any of the elements is not null: if len(a) > 0 and…
-
0
votes1
answer34
viewsA: @Html.Action in _Shared error when sending a Viewmodel by Controller
The correct way to do this is by making a derivation of oneself Controller, thus: public class Controller : System.Web.Mvc.Controller { public PartialViewResult Rodape() { using (WMBContext db = new…
-
2
votes1
answer579
viewsA: How to store passwords in environment variables (and remove them from version control)?
How do you do it? Environment variables? If you already encrypt your web.config, no need to worry about the security of information, right? Basically, just encryption already solves the security…
-
5
votes2
answers882
viewsA: What is the importance of using java interfaces or c#?
Basically, an interface is a contract, usually established for use between two distinct components, such as a system and a library, for example, or to reduce restrictions on the use of objects.…
-
4
votes2
answers650
viewsA: Reference class Syntax Razor C#
I will teach you two more sophisticated methods to obtain strongly typed values in your View. Method 1: By derivation System.Web.Mvc.WebViewPage Create something like this: namespace…
-
5
votes1
answer479
viewsA: split a string of n into n chars, split() of n n
Thus: texto = "ola sou o Allan" lista = [texto[i:i+2] for i in range(0, len(texto), 2)] I took it from here. Running: >>> texto = "ola sou o Allan" >>> lista = [texto[i:i+2] for i…
pythonanswered Leonel Sanches da Silva 88,623 -
7
votes2
answers680
viewsA: Disable css and image caching in the browser
In ASP.NET MVC, this is done through a global filter using the OutputCacheAttribute. The following code can be placed on Global.asax.cs: public static void…
-
0
votes1
answer126
viewsA: ASP.NET MVC Default Page
You have configured your project so that no Controller is accessible to those who are not logged in: <authorization> <deny users="?"/> </authorization> Remove these lines from your…
-
1
votes1
answer306
viewsA: Receive post from one view to another view
Use TempData[] would be a good way to solve that problem or is there another way to do? No. The problem is another one here. You’re making one load of something that does not have and cannot receive…
-
0
votes2
answers1042
viewsA: Python - Selenium send_keys() does not work in this form field
Why not select directly by id? campo = driver.find_element_by_css_selector('#yui-gen19')
-
2
votes1
answer168
viewsA: 404 when setting an app.route in Flask
This: @app.route("/") def hello(): return "Hello World!" Generates a route default in your website instance. When you switch to: @app.route("/Teste") def hello(): return "Hello World!" The route…
-
1
votes1
answer3861
viewsA: Catch the time of formatted sql server database
It’s just the sign of + you don’t need. The rest is right. select CONVERT(VARCHAR(5), CAST(HORA_FECHAMENTO AS datetime), 108) as HORA_FECHAMENTO, CONVERT(VARCHAR(5), DATEADD(hour, 4, getdate()),…
-
3
votes1
answer2071
viewsA: Making a select in all tables of a schema
The following function implements what you need: CREATE OR REPLACE FUNCTION search_columns( needle text, haystack_tables name[] default '{}', haystack_schema name[] default '{public}' ) RETURNS…
-
0
votes1
answer218
viewsA: Connection String not found WPF Entity Framework
This seems to me bad project setup. The configuration file is ok but apparently not being properly recognized. There are a few things you can do to get around the problem quickly: 1. Not using…
-
2
votes1
answer334
viewsA: MVC - Keep Partialview loaded when Modelstate is not valid
There are a lot of bad practices here. Within your method Salvar, you have: public virtual ActionResult Salvar(TViewModel model) { if (ModelState.IsValid) { if (model.Operacao.Equals("I"))…
-
0
votes1
answer86
viewsA: Scrapy queueQueue and mysql store
This is a bad practice? No, considering the responsibility for handling the Mysql connection is also being done using good Python practices. I can use the -s JOBDIR=crawls/somespider-1 to pause and…
-
3
votes2
answers447
viewsA: How to make a loop that compares string with a python float?
Explicit conversion to float: h = float(input("Informe sua altura: ")) See more here.…
pythonanswered Leonel Sanches da Silva 88,623 -
3
votes2
answers216
viewsA: View Model should have related classes?
My doubt is at the time of creating the Viewmodels, I would have to have within Managerviewmodel a property of type "Personaldataviewmodel" and within Personaldataviewmodel a property of type…
-
2
votes1
answer1049
viewsA: Date Issue in ASP.NET MVC
This is solved by implementing a DateTimeModelBinder: public class DateTimeModelBinder : DefaultModelBinder { public override object BindModel(ControllerContext controllerContext,…
-
0
votes1
answer121
viewsA: Invoke selected Checkbox values in View Edit
This is the bad way to do it. The right way involves using @Html.ListBox or @Html.ListBoxFor: @Html.ListBoxFor(m => m.SelectDias, (MultiSelectList)ViewBag.Daylist)…
-
1
votes1
answer139
viewsA: How to make a video file available for viewing in the browser as PDF?
You should not serve video as a file, but as a Stream. To do this, implement a class that prepares the Stream from the video to you: public class VideoStream { private readonly string _arquivo;…
-
2
votes2
answers732
viewsA: How to structure a solution by separating Webapi from Webui using ASP.NET Identity?
The shape I use is: MeuProjeto.Dominio (Models, Enums, Helpers and Non-visual Extensions, ASP.NET Identity); MeuProjeto.MVC (Controllers, Views); MeuProjeto.WebApi (Apicontrollers). Both the Entity…
-
3
votes1
answer1103
viewsA: Asp.Net MVC authentication using Formsauthentication
The authentication is working, however I am not very sure if this would be the best form of authentication given that the application will be available to N users (can have more than 1000 logged in…