Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [asp.net]

ASP.NET is a web application framework developed by Microsoft to allow programmers to build dynamic web sites and web applications.

0
votes
1answer
31 views

StringBuilder returing Web script

Task : With the page_type and currentpage param I made this code that returns the web script of the web page with active class on the current page through aspx behind code. Is there a better and a ...
-1
votes
1answer
51 views

Check if mail contains a single page pdf and transfer to other folders

This code checks if a mail message contains a single page PDF attachment. If yes, it adds it to a processed list else rejected list. If mail can be processed, then it saves the attachment into a file....
1
vote
0answers
39 views

Max number of concurrent tasks in asp.net [closed]

Background I have a highly available asp.net (4.5.2) web api receiving very high load. The app primarily reads from a Redis cluster, processes/formats the data & returns in json or protobuf. Due ...
2
votes
1answer
50 views

Displaying all application errors in a view

I'm learning ASP.NET Core with MVC pattern and I didn't find anything useful related to this argument. Actually I'm looking ...
2
votes
2answers
96 views

Subscribe to Event form one service to another

In my architecture I have service layer, and for my question two relevant classes in this layer: UserManagementService EmailSenderService In first service there is method: ...
2
votes
1answer
910 views

asp.net core - get User at Service Layer

I use ASP.NET Core 2.1 and would like to fetch User at a service level. I've seen examples when HttpContextAccessor gets ...
1
vote
1answer
417 views

Async await multiple API calls

I have an application that needs to contact a remote API many times to request information about various products. It was taking around a minute with synchronous programming. I adjusted all my methods ...
5
votes
2answers
102 views

ASP.NET HTML code generation, two approaches

I was asked to give more context. So here we go. We want to create some HTML in code behind to add an "add" and a "refresh" button to a grid view header column. Approach #1 does this using string ...
3
votes
1answer
326 views

Proper way to display form with filtering in ASP.NET MVC 5

I want to create page when user can use form to display filtered data in table. Form has to remember its own state, because after every refresh it shouldnt change. So after submitting form I should ...
5
votes
1answer
304 views

Convert IEnumerable<Reads> to CSV

I have an IEnumerable of a view model that I need to convert to CSV and send back as a file response. I have written it out quite manually and I'm just seeking code ...
3
votes
1answer
303 views

Giving error response in Web API

I'm creating a Web Api in .NET Framework that is connected to an ASMX service. No own logic, just pass through data. Everything works as expected. But not sure if it's good. Have to repeat the same ...
2
votes
0answers
92 views

How to optimize code to only pull separate table rows that are necessary

I have a Company Class, and separate normalized Address Class. I did this because the Address table will hold more than just Company Addresses, so I don't want "CompanyAddress", "EmployeeAddress", "...
2
votes
1answer
75 views

UserStore implementation for two databases

I created our UserStore class to use it with our custom database membership. We use two databases: AMDbContext host the main ...
1
vote
2answers
131 views

Function to download anonymous type data into excel

As far as I know, I cannot create function to accept anonymous type as parameter and I am reluctant to create new class to store those anonymous type because their difference is ...
1
vote
1answer
93 views

Getting value from session if available, if not, take from the database

This method is a constructor that has to decide which URL to add to the response header as Allow-Origin. i am actually adding the Allow-Origin later according to the value of PermittedOrigion variable....
3
votes
2answers
94 views

Image Database Service

I created simply database service with get, insert, get all image names and verify exist method. All images will be store in blob storage with unique filename + postfix size. Next one I have image ...
2
votes
4answers
473 views

Find consecutive numbers and turn them into ranges

I have array int[] arr = { -2, 0, 1, 2, 3, 4, 5, 8, 9, 11, 13, 15, 18, 22, 25, 28, 29, 30 }; I need to write function that shows it as string and if numbers are ...
0
votes
1answer
65 views

Get Users and related roles and show on View

I have 3 tables. Users, Roles and RolesToUsers Here is User model: ...
4
votes
1answer
552 views

Runs a MySQL query, returns Dictionary<string, string> or false;

I've been practicing C# and ASP.NET, and have been working on a somewhat larger-scale project than I am currently used to. I am sure there are horrible things wrong with this code that I will find out ...
2
votes
1answer
55 views

IsDatabaseUp returns true or throws exception

I want to write an ASP.NET Web API endpoint that allows clients to check if database is running. The method below is check if database is up by establishing a connection and running a dummy sql ...
4
votes
1answer
155 views

Generic class for Unit of Work pattern

In my project I use the Unit of Work pattern and it works really well. The implementation is the following: ...
6
votes
2answers
250 views

Update SQL database, similar-but-different queries for each month

This snippet works and does as desired, but I just wonder if I am being too repetitive. What I mean by this is, eventually I will have all 12 months in there. So.... 12 Update Queries, 12 Commands, ...
1
vote
1answer
409 views

Change Background Color of ASP:GridView Based On Text

I am using the OnRowDataBound() event to change the Row.BackColor based on the text. Now my issue is, this is extremely slow. ...
2
votes
0answers
312 views

RESTful API combining three other APIs

I have created a RESTful API that uses three other APIs with Visual Studio 2017 in .NET Core. It is the first time I have ever programmed in .NET so I am sure the code could use a lot of improvements. ...
1
vote
0answers
54 views

Populating a container with dynamic pairs of connected sortable lists

I am working on an application which is used to assign work to Operators based on the Category of the work. Each Operator has several Categories of work they are qualified to work on. They have a ...
3
votes
4answers
145 views

Query URL parameters in downloading pictures from network cameras

I have some URLs saved in my database, to download pictures from network cameras. Because each camera has it's own URL and parameters, we have to store the entire URL in a field in the database. My ...
2
votes
2answers
2k views

Simple login user authentication

I've created a simple User Login page. Here User is authenticated [username, password] and if it is a valid user, values like username, name and role of the user is ...
1
vote
1answer
148 views

Calculating difference in time

In table first value I have value with datatype = Start I need to calculate difference first value - midnight Last value is ...
0
votes
3answers
772 views

Repository with ViewModel (ASP.NET MVC)

I have db table Model. Here is code: ...
1
vote
1answer
869 views

Implementing integration tests in ASP.NET core using InMemory database

I am building a web application using ASP.NET core. Most of the tests in my application are unit tests, so I mocked every dependencies in order to have fast unit tests. On the other hand I am of the ...
4
votes
1answer
5k views

Make external js file in ASP.NET MVC with razor path

I have js code , that I decided to move to external js. In this code I have razor syntax (url path) Here is code of those functions ...
1
vote
0answers
92 views

Add or modify bunch of data into database

I got my code works fine, but I am not really sure whether the approach that I took is a best practice or not. So, I decided to ask in this forum instead. So here is my situation: I got my model ...
2
votes
1answer
70 views

Adding data to database using ASP.net and SQL-server part 2

This is a continuation of my question in this link: Adding data to database using asp.net and sql-server. Now I have already incorporated the solutions that was provided in the given link. First ...
1
vote
1answer
29 views

Dual rewrite rules (WWW prefix and HTTPS)

I want to configure my website to force a www. prefix on the name, and the HTTPS protocol. ...
3
votes
1answer
83 views

Adding data to database using asp.net and sql-server

I just want to know your suggestions on improving my code on adding data to the database using asp.net and sql-server. Basically, I've created a form that the admin will fill-up and then when he ...
4
votes
2answers
2k views

Log Visitor Count in Asp.net MVC

I have a table to Log visitor Count Like : ...
-1
votes
1answer
1k views

If and else without curly brackets [closed]

Is it possible to have an if condition with curly brackets and else conditions without brackets? Also what is the good practice to format it , should there be a new line after else keyword? ...
-1
votes
1answer
195 views

Partition TPL Tasks in ASP.net 4.0 for WCF Service

Want to know if using partition code like this is ok to do to partition tasks in ASP.NET 4.0 inside of a WCF service. My goal with this code is to try to do non-blocking calls without spinning up too ...
2
votes
2answers
266 views

Sort a list for a GridView

I've written the following piece of code to sort my list, which is the data source to my GridView, depending on the column to be sorted on. It seems to me that there is quite a bit of redundancy, and ...
0
votes
1answer
68 views

Rendering logos for guitars and basses listed in a database

Right now I'm still a beginner in databases and still learning all about it. I have a problem with the design of my database and I don't really know where to go from here. Basically I'm building a ...
1
vote
2answers
5k views

Calculating the total of each column and display in footer of gridview in DataTable

I've used this code to get the sum of the values of each column and display in footer. Here, the advantage is that I don't have to look for the column name, just get the count of total number of rows ...
2
votes
0answers
246 views

JS/ASP.NET quiz app

I finally have a working version of my quiz web/game app. I used C# ASP.NET MVC with Entity Framework and JavaScript/Jquery. Would you guys mind taking a look at my code and make suggestions/...
3
votes
2answers
141 views

REST API for user access using ASP.NET Core

I have been coding in java for more than 3 years. Recently we had to develop REST Web Services for our customers in ASP.NET Core. I am a newbie to both C# and ASP.NET Core stack. The expectation ...
0
votes
1answer
613 views

Searching of Word documents

I have a website that offers to search documents from local hearings conducted, stored on a network file server. I need to take in the search term and search a bunch of .docx (roughly 4500) files. ...
3
votes
1answer
64 views

SqlConnection Transaction Management Approach

I am currently working on a SharePoint 2013 project with custom application pages development. On one of those pages, there are multiple insert / update to database table operations. Here are the ...
1
vote
0answers
91 views

Retain previous values in Label

I am trying to write a simple program, from which the following can be achieved. Button1_Click, the number on the Button is increased by 1. The increased number is ...
2
votes
0answers
47 views

Creating many aspx pages

I just want to ask if its okay to create many aspx pages. What i did was, i made a guitar store website that has 6 brands and each of them have their own webpage. The code is like this: The aspx.cs ...
4
votes
1answer
2k views

Retrieving data in an SQL database and displaying the retrieved data in ASP.NET

I wanted to know other ways where you can access data from the database into the asp.net website that I've created for displaying details and images. As well as looking for better ways to use those ...
1
vote
1answer
74 views

Custom error page with information tokens implementation

I have created custom error pages (for 500 and 404 http codes) for asp.net web site. After an error, application should create new entry in database in Logs table with information about error. Each ...
4
votes
1answer
11k views

Update SQL database with using statement and SqlParameters

I'm just starting out to learn all about sql databases. For now based on previous suggestions that was given to me online, I've incorporated a using statement to avoid problems in sql connection and ...