Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
0
votes1
answer49
viewsA: id3 display album image in mp3 file using c# mvc Razor
This library does in a practical way what you need. This extension will also be required. The idea is you convert this PictureManager for Web. The idea is to load the file using a PictureFrame. The…
-
2
votes2
answers2294
viewsA: Scraping in Python - read pdf
Using Python and pdfminer (pdfminer3k for Python 3), I implemented PDF reading through the following class: import pdfminer from pdfminer.pdfinterp import PDFResourceManager, process_pdf from…
-
1
votes1
answer104
viewsA: Logging into a website using Webrequest
Do Login return bool: public bool Login(string loginPageAddress, NameValueCollection loginData) { try { CookieContainer container; var request = (HttpWebRequest)WebRequest.Create(loginPageAddress);…
-
1
votes1
answer46
viewsA: How to render 2 typed view from different controllers
The right way is to bring everything into the same Action: public ActionResult Index() { Cliente cli = new Cliente(); cli.Nome = "Al Unser"; cli.Pedidos = new List<Pedido> { // Lance aqui seus…
-
1
votes1
answer150
viewsA: Customizing width of Textboxfor
Note that the style of input is fixed at 250px: <input class="form-control" id="Nome" name="Nome" style="width: 250px; height: 30px;" type="text" value="Benício Calebe Giovanni Araújo" />…
-
1
votes2
answers778
viewsA: Post Sends data but webapi captures null
This is the wrong way to pass parameters to your Controller. If the idea is to pass a complex type, the best way to do it is to create a class that receives this data, taking advantage of the…
-
0
votes2
answers292
viewsA: How does the flow of a Web Service work?
How the flow of a Web Service works? The working principle may well be answered for this excellent question and its answers, a few more additions. There are several protocols that implement a Web…
-
3
votes2
answers291
viewsA: How to standardize Datetime format for all type fields without using Displayfor or Editorfor in MVC?
How to standardize this at once using MVC? Using DisplayFor and EditorFor. Anything other than that, considering only Razor, is incorrect. Another thing is about using only the date, not the time…
-
1
votes1
answer1783
viewsA: Webmatrix - CS0103: The name 'Viewbag' does not exist in the current context
Let me give you an example of Views/Web.config of ASP.NET MVC5 (I am looking for a good example of MVC4 but it is difficult, and so I asked if it was possible to change the version of framework):…
-
1
votes1
answer928
viewsA: How to treat a decimal field with no homes after comma in a jquery mvc c#mask
Your question does not make much sense. First, because you are treating an entire as decimal, saving as decimal and yet wanting the field to behave as whole on screen. Obviously it won’t work right.…
-
2
votes1
answer222
viewsA: Validating Empty Dropdownlist
What should I do? Mark the property of Model with [Required]: [Required] public int HorasPendenciaID { get; set; } If the validation messages are in English, install this Nuget package.…
-
9
votes2
answers1101
viewsA: Entity Framework Core x Entity Framework 7
None Entity Framework 7 was renamed Entity Framework Core. The goal is not to create an impression that Entity Framework 6 can be upgraded to Core (as might suggest 7 as the natural sequence of…
-
3
votes1
answer79
viewsA: Null attribute check in @Html.Displaynamefor
It’s not much of a secret: @if (Model.DataFinalizacao != null) { <div class="label label-primary"> @Html.DisplayNameFor(model => model.DataFinalizacao) </div> <div…
-
4
votes1
answer1263
viewsA: App.config how to use`Connectionstring` encrypted
As I said in comment, use instead of the name of Connection string: SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString); In cryptography, the name…
-
2
votes1
answer399
viewsA: Alternative to the Transactionscope
There is no need to open two contexts within a transaction scope. Do this using the same context: using (var ts = new System.Transactions.TransactionScope()) { using (var context = new MyEntities())…
-
0
votes1
answer308
viewsA: Charset problem between Asp.Net MVC with Entity Framework and SQL Server
This is wrong here: <globalization culture="pt-BR" uiCulture="pt-BR" requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" fileEncoding="iso-8859-1" /> The default ASP.NET MVC is the…
-
1
votes2
answers2059
viewsA: Upload Image Asp net MVC
What’s the best way to solve this? I wanted the images to come back too. Using the Backload. It is a package that manages a session of upload of files in ASP.NET (can be MVC or Web Forms). An…
-
1
votes1
answer140
viewsA: How to identify an http (500) error via the Selenium web driver or javascript
Can anyone tell me if Selenium has any commands for this, or javascript? Selenium itself, no. What you can do is fire a request using a shared session and collect the error status. The package I…
-
0
votes1
answer69
viewsA: HTML attributes on webgrid lines
You can include the data-id-task="@item.id" attribute within each TR using Webgrid? Not. WebGridRow has no methods to work with fields data-. Prefer to use a <table> normal within the…
-
0
votes1
answer233
viewsA: Upload _Layout.cshtml information from database
What’s the best way to do it? Doing nothing. ASP.NET MVC has a property HttpContext.Cache that caches automatically for you. You just need to set the following in your Controller common: public…
-
3
votes2
answers376
viewsA: Span inside @Html.Actionlink
Use @Url.Action instead of @Html.ActionLink: <td style="font-size:10%"> <p class="list-group-item-text"> <a href="@Url.Action("Cidade", "Cidade", new { cidadecod = item.cidadecod,…
-
1
votes1
answer445
viewsA: Group query by similar but non-identical records
In my view, the first thing you should get is the list of terms used in a given column (whose answer I took from here): CREATE FUNCTION dbo.Split ( @RowData nvarchar(2000), @SplitOn nvarchar(5) )…
-
1
votes4
answers188
viewsA: SQL Embedded in C#
What would be the approach for the database to be embedded in the application, so that it can be executed without being connected to any server? A good approach is the SQL Server Localdb. It is…
-
1
votes2
answers342
viewsA: Redirect from Http to Https on Owin + Oauth + Google Externallogin
This should not be solved by code. This should be solved by IIS configuration. The best way is to insert in your Web.config the following: <configuration> ... <system.webServer> ...…
-
3
votes3
answers151
viewsA: How to create extension methods in the Entity Framework using Linq?
You can create custom extension methods for Linq to entities? Yes, but that’s a bit complex. I’ll explain the guidelines on how to do this. Linq to Entities translates each extension method into a…
-
2
votes1
answer492
viewsA: Creating Models that derive Identityuser or use the Aspnetusers table
However it would not be better to use the table already created by Identity Aspnetusers? This form already uses this table. What happens is that the Models bred IdentityUser will all records from…
-
1
votes2
answers66
viewsA: How to create a text file template?
Ideally, you should establish a convention for the texts that should be replaced, with some symbol or punctuation type for the variables in your file. For example, :{} The following function can be…
c#answered Leonel Sanches da Silva 88,623 -
4
votes1
answer3398
viewsA: Foreign Key Sql Server
..., what is the best solution to create an FK in such a situation? Pointing foreign keys only to primary keys. For example: CREATE TABLE UF ( ID_UF INT PRIMARY KEY IDENTITY, Cod_UF INT NOT NULL,…
-
1
votes1
answer1107
viewsA: A3 Certificate in ASP.NET MVC and IIS
It is possible to make the OSI "respect" the code above in the same way that the IISEXPRESS does? No. This is not a problem with the OSI. The point is that you are using an A3 Certificate (hence a…
-
5
votes1
answer356
viewsA: How to change the template(visual) of an Asp net mvc5 page according to user
The secret lies in the definition of a Actionfilter. For example: public class LayoutChooserAttribute : ActionFilterAttribute { public override void OnActionExecuted(ActionExecutedContext…
-
-3
votes2
answers475
viewsA: Is it possible to run ASP.NET MVC without IIS?
It is possible to run an Asp.net mvc application without IIS? In short, no. ASP.NET MVC4 is very dependent on IIS. I wish the user could run this application Asp.net mvc without having to configure…
-
0
votes1
answer223
viewsA: Define model the two-dimensional Array type attribute
In the Model created attributes with multiple columns and in controller use a list of type enumerable with 20 positions, but did not find it cool because I want the mounting of the array was more…
-
0
votes1
answer56
viewsA: How to update a User Entity that is converted into application?
The error is crystal clear. You are adding the same object to the context twice. Here: db.Users.Attach(usr.ToApplication()); And here: db.Entry(usr.ToApplication()).State =…
-
17
votes1
answer480
viewsA: Passing parameters with Asp.Net MVC
ViewData It is a temporary dictionary of values that serves to pass auxiliary information between Controller and View. Exists only during request processing. It’s the most rudimentary way to pass…
-
0
votes1
answer139
viewsA: Controller get checkbox list from a view
..., remembering that I put a check in manual, which is not a property of my viewmodel. This doesn’t make much sense. In fact, there’s no way Controller guess what you selected on screen. You need…
-
1
votes1
answer54
viewsA: How to use areas only using root controller
I’ve found a way, but I need to know if she’s coherent, not a gambit. It’s a scam. You’re actually doing the Controller have to interpret the route getting the requested area by request, which is…
-
2
votes1
answer588
viewsA: Is it possible to leave connectionString dynamically?
What I would do, instead, is map a context of user information separately. It stores not only the connection data to the user’s database, but also additional information about the login and its…
-
1
votes1
answer160
viewsA: LEFT Outer Join does not work on LINQ when 0 is the reference? null only
Your model does not allow the Fornecedor be null. It would need to be so: public class fechamentoMovimentacao { public int MovimentacaoId { get; set; } public int? FornecedorId { get; set; } // Aqui…
-
4
votes2
answers488
viewsA: Web Paging with C#
Another good option is to use one of the two components below: Pagedlist.Mvc, seemingly discontinued, with support to async in this other package; X.PagedList.Mvc, natural continuation of Pagedlist,…
-
0
votes2
answers3095
viewsA: How to pass variables from Controller to View in ASP.NET MVC 4.5?
The correct way to send validation errors from Controller to the View is through the command ModelState.AddModelError(): [HttpPost] public void Attempt(string email, string password, Admins db) {…
-
1
votes1
answer52
viewsA: View model with Icollection
The separation into Viewmodels is only required if the presentation of data (Views) is different from what is proposed in Model. That is, if your Model is like this: public int CategoriaId { get;…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
2
votes1
answer867
viewsA: Update multiple databases using code first without using console
Set the following in your configuration file (Web.config): <configuration> ... <entityFramework> <defaultConnectionFactory…
-
2
votes1
answer764
viewsA: ASP.NET MVC error when displaying date and time fields in View
It’s not gonna work here: [DataType(DataType.Date)] [Display(Name = "Ínicio do contrato")] [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")] public DateTime?…
-
1
votes1
answer454
viewsA: Return Partialview with validations for a Modal ASP MVC 4
If the idea is to bring a Modal to register new records, the use of Partials interacting with the Controller is unnecessary. As good practice, Modal can stay hidden and be displayed through simple…
-
2
votes1
answer1179
viewsA: Error entering data into database, EF 6
As stated by comment, the correct way to resolve it is by using the Entityframework.Bulkinsert, that has Nuget package. An example of use would be: using EntityFramework.BulkInsert.Extensions;…
-
2
votes1
answer85
viewsA: What is the best alternative to recording data using a 3G connection?
In this case, it would be feasible to record the header, perform the recovery of the last recorded ID for the user and write the Items or it would be better to do a precedent and leave this…
-
0
votes1
answer95
viewsA: Linking Users to Businesses and bringing related records to the User’s company using ASP.NET Identity and Entity Framework
The ideal is that your Usuario own the property EmpresaId as follows: public class Usuario : IdentityUser { public int EmpresaId { get; set; } public virtual Empresa Empresa { get; set; } } Thus,…
-
2
votes1
answer4054
viewsA: Call View in another ASP.NET MVC Controller
The use of RedirectToAction is wrong. That’s how: return RedirectToAction("Index", "Home"); See all possible uses here.…
-
1
votes1
answer86
viewsA: How to set up an Authentication and Authorization Server?
Has anyone ever done this work for you, with more features than the example link. See the setup steps here.…
-
2
votes1
answer63
viewsA: Does Not Record IIS error System.Diagnostics.Xmlwritertracelistener
In accordance with by comment, check the Application Pool user’s permission (normally IIS APPPOOL\DefaultAppPool) or still the IIS user (usually IUSR in IIS7). See more about IIS accounts here.…