Skip to main content

Questions tagged [asp.net]

ASP.NET is a Microsoft web application development framework that allows programmers to build dynamic web sites, web applications and web services. It is useful to use this tag in conjunction with the project type tag e.g. [asp.net-mvc], [asp.net-webforms], or [asp.net-web-api]. Do NOT use this tag for questions about ASP.NET Core - use [asp.net-core] instead.

Filter by
Sorted by
Tagged with
2159 votes
42 answers
810k views

How do I format a Microsoft JSON date?

I'm taking my first crack at Ajax with jQuery. I'm getting my data onto my page, but I'm having some trouble with the JSON data that is returned for Date data types. Basically, I'm getting a string ...
1592 votes
48 answers
1.2m views

A potentially dangerous Request.Form value was detected from the client

Every time a user posts something containing < or > in a page in my web application, I get this exception thrown. I don't want to go into the discussion about the smartness of throwing an ...
Radu094's user avatar
  • 28.3k
1520 votes
41 answers
498k views

Path.Combine for URLs?

Path.Combine is handy, but is there a similar function in the .NET framework for URLs? I'm looking for syntax like this: Url.Combine("http://MyUrl.com/", "/Images/Image.jpg") which would return: "...
Brian MacKay's user avatar
  • 31.7k
1445 votes
31 answers
761k views

JavaScriptSerializer - JSON serialization of enum as string

I have a class that contains an enum property, and upon serializing the object using JavaScriptSerializer, my json result contains the integer value of the enumeration rather than its string "...
Omer Bokhari's user avatar
  • 58.9k
1315 votes
61 answers
830k views

Could not find a part of the path ... bin\roslyn\csc.exe

I am trying to run an ASP.NET MVC (model-view-controller) project retrieved from TFS (Team Foundation Server) source control. I have added all assembly references and I am able to build and compile ...
Eyad's user avatar
  • 14k
1179 votes
16 answers
997k views

Maximum request length exceeded.

I am getting the error Maximum request length exceeded when I am trying to upload a video in my site. How do I fix this?
Surya sasidhar's user avatar
1148 votes
24 answers
1.5m views

How to set the Content-Type header for an HttpClient request?

I'm trying to set the Content-Type header of an HttpClient object as required by an API I am calling. I tried setting the Content-Type like below: using (var httpClient = new HttpClient()) { ...
mynameiscoffey's user avatar
970 votes
18 answers
1.2m views

If a folder does not exist, create it

I use a FileUploader control in my application. I want to save a file to a specified folder. If this folder does not exist, I want to first create it, and then save my file to this folder. If the ...
Tavousi's user avatar
  • 15.3k
941 votes
19 answers
1.6m views

Change the selected value of a drop-down list with jQuery

I have a drop-down list with known values. What I'm trying to do is set the drop down list to a particular value that I know exists using jQuery. Using regular JavaScript, I would do something like: ...
phairoh's user avatar
  • 10.5k
927 votes
14 answers
460k views

Ajax request returns 200 OK, but an error event is fired instead of success

I have implemented an Ajax request on my website, and I am calling the endpoint from a webpage. It always returns 200 OK, but jQuery executes the error event. I tried a lot of things, but I could not ...
Pankaj Mishra's user avatar
911 votes
43 answers
1.4m views

Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters

I want a regular expression to check that: contains at least eight characters, including at least one number and includes both lower and uppercase letters and include at least one special characters, ...
Swapnil Tatkondawar's user avatar
887 votes
23 answers
268k views

ASP.NET Web Site or ASP.NET Web Application?

When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site. What is the difference between ASP.NET Web Application and ASP.NET ...
Robert S.'s user avatar
  • 25.3k
824 votes
12 answers
685k views

How can I retrieve Id of inserted entity using Entity framework?

I have a problem with Entity Framework in ASP.NET. I want to get the Id value whenever I add an object to database. How can I do this? According to Entity Framework the solution is: using (var context ...
ahmet's user avatar
  • 8,273
800 votes
20 answers
800k views

In C#, what is the difference between public, private, protected, and having no access modifier?

All my college years I have been using public, and would like to know the difference between public, private, and protected? Also what does static do as opposed to having nothing?
MrM's user avatar
  • 21.9k
786 votes
12 answers
331k views

How do I import a namespace in Razor View Page?

How to import a namespace in Razor View Page?
Amitabh's user avatar
  • 60.4k
739 votes
36 answers
445k views

How do you create a dropdownlist from an enum in ASP.NET MVC?

I'm trying to use the Html.DropDownList extension method but can't figure out how to use it with an enumeration. Let's say I have an enumeration like this: public enum ItemTypes { Movie = 1, ...
738 votes
9 answers
1.4m views

How to get the URL of the current page in C# [duplicate]

Can anyone help out me in getting the URL of the current working page of ASP.NET in C#?
user avatar
736 votes
31 answers
798k views

Can I set an unlimited length for maxJsonLength in web.config?

I am using the autocomplete feature of jQuery. When I try to retrieve the list of more then 17000 records (each won't have more than 10 char length), it's exceeding the length and throws the error: ...
Prasad's user avatar
  • 59.3k
729 votes
53 answers
1.6m views

The request was aborted: Could not create SSL/TLS secure channel

We are unable to connect to an HTTPS server using WebRequest because of this error message: The request was aborted: Could not create SSL/TLS secure channel. We know that the server doesn't have a ...
Simon Dugré's user avatar
  • 18.7k
682 votes
16 answers
311k views

Escape @ character in razor view engine

I am creating a sample ASP.NET MVC 3 site using Razor as view engine. The razor syntax starts with @ character e.g. @RenderBody(). If I write @test on my cshtml page it gives me parse error CS0103: ...
ajay_whiz's user avatar
  • 17.9k
676 votes
9 answers
229k views

ASP.NET MVC - Set custom IIdentity or IPrincipal

I need to do something fairly simple: in my ASP.NET MVC application, I want to set a custom IIdentity / IPrincipal. Whichever is easier / more suitable. I want to extend the default so that I can call ...
Razzie's user avatar
  • 31.1k
609 votes
53 answers
1.1m views

IIS 500.19 with 0x80070005 The requested page cannot be accessed because the related configuration data for the page is invalid error

I want to upload my own asp.net website on IIS with IIS Manager. But when I do this, I get the following error HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed ...
Yasmeen's user avatar
  • 11.3k
607 votes
22 answers
410k views

Unable to update the EntitySet - because it has a DefiningQuery and no <UpdateFunction> element exist

I am using Entity Framework 1 with .net 3.5. I am doing something simple like this: var roomDetails = context.Rooms.ToList(); foreach (var room in roomDetails) { room.LastUpdated = ...
Positonic's user avatar
  • 9,351
590 votes
9 answers
123k views

Compile Views in ASP.NET MVC

I want an msbuild task to compile the views so I can see if there are compile time errors at well... compile time. Any ideas?
John Oxley's user avatar
  • 14.9k
548 votes
27 answers
423k views

How to enable external request in IIS Express?

How can I enable remote requests in IIS Express? Scott Guthrie wrote that is possible but he didn't say how.
TedTel's user avatar
  • 5,495
538 votes
16 answers
827k views

How to Deserialize XML document

How do I Deserialize this XML document: <?xml version="1.0" encoding="utf-8"?> <Cars> <Car> <StockNumber>1020</StockNumber> <Make>Nissan</Make> ...
Alex's user avatar
  • 40k
526 votes
4 answers
323k views

What is the difference between 'classic' and 'integrated' pipeline mode in IIS7?

I was deploying an ASP.NET MVC application last night, and found out that it is less work to deploy with IIS7 set to integrated mode. My question is what is the difference? And what are the ...
Jon Erickson's user avatar
499 votes
38 answers
527k views

Login failed for user 'IIS APPPOOL\ASP.NET v4.0'

I have a web project (C# Asp.Net, EF 4, MS SQL 2008 and IIS 7) and I need to migrate it to IIS 7 locally (at the moment works fine with CASSINI). Locally in IIS I have my Default Web Site with my ...
GibboK's user avatar
  • 73.3k
493 votes
13 answers
474k views

WCF - How to Increase Message Size Quota

I have a WCF Service which returns 1000 records from database to the client. I have an ASP.NET WCF client (I have added service reference in asp.net web application project to consume WCF). I get ...
bugBurger's user avatar
  • 6,950
492 votes
21 answers
197k views

Stop Visual Studio from launching a new browser window when starting debug?

I already have a window open with the web site I'm debugging. I don't need VS to launch another one for me every time I need to debug. Is there a way to stop this behavior?
sker's user avatar
  • 18.2k
488 votes
30 answers
522k views

Get MIME type from filename extension

How can I get the MIME type from a file extension?
user avatar
488 votes
18 answers
233k views

jQuery $(document).ready and UpdatePanels?

I'm using jQuery to wire up some mouseover effects on elements that are inside an UpdatePanel. The events are bound in $(document).ready . For example: $(function() { $('div._Foo').bind("...
Herb Caudill's user avatar
  • 49.8k
483 votes
20 answers
276k views

Can an ASP.NET MVC controller return an Image?

Can I create a Controller that simply returns an image asset? I would like to route this logic through a controller, whenever a URL such as the following is requested: www.mywebsite.com/resource/...
Jonathan's user avatar
  • 32.7k
476 votes
40 answers
1.1m views

HTTP Error 503, the service is unavailable

I'm really new to setting up web servers in general. I've got IIS 8 on Windows 8, and I'm trying to set up a little site locally, while doing some development. In IIS I choose Add Site, give a name, ...
Andreas's user avatar
  • 5,571
475 votes
4 answers
522k views

Server.MapPath("."), Server.MapPath("~"), Server.MapPath(@"\"), Server.MapPath("/"). What is the difference?

Can anyone explain the difference between Server.MapPath("."), Server.MapPath("~"), Server.MapPath(@"\") and Server.MapPath("/")?
Manu's user avatar
  • 29k
445 votes
40 answers
797k views

Cannot read configuration file due to insufficient permissions

I've recently encountered an error trying to host my asp.net site with IIS. I have found a solution that many swear by. Solution: Add IIS_IUSRS with Read permission on files in the folder Change ...
Freesnöw's user avatar
  • 31.7k
444 votes
9 answers
119k views

One DbContext per web request... why?

I have been reading a lot of articles explaining how to set up Entity Framework's DbContext so that only one is created and used per HTTP web request using various DI frameworks. Why is this a good ...
Andrew's user avatar
  • 11.2k
435 votes
14 answers
501k views

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode

I installed DotNetOpenAuth SDK-3.4.5.10201.vsix, and I can't get it working. It works locally (when I run as localhost), but when I try to publish it doesn't work. The IIS error message I get is: ...
Mikael's user avatar
  • 5,439
435 votes
4 answers
341k views

IIS AppPoolIdentity and file system write access permissions

Here's an issue with IIS 7.5 and ASP.NET that I've been researching and getting nowhere with. Any help would be greatly appreciated. My question is: using ASP.NET in IIS 7.5, how does IIS and/or the ...
rsbarro's user avatar
  • 27.2k
434 votes
11 answers
640k views

POSTing JsonObject With HttpClient From Web API

I'm trying to POST a JsonObject using HttpClient from Web API. I'm not quite sure how to go about this and can't find much in the way of sample code. Here's what I have so far: var myObject = (...
Mark's user avatar
  • 21.5k
433 votes
50 answers
355k views

How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?

Sometimes when I'm editing page or control the .designer files stop being updated with the new controls I'm putting on the page. I'm not sure what's causing this to happen, but I'm wondering if there'...
432 votes
30 answers
466k views

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive

I'm trying to up load my site and I'm getting this error message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive. <compilation debug="true" ...
Mike Nacci's user avatar
  • 4,319
430 votes
22 answers
748k views

How to get a user's client IP address in ASP.NET?

We have Request.UserHostAddress to get the IP address in ASP.NET, but this is usually the user's ISP's IP address, not exactly the user's machine IP address who for example clicked a link. How can I ...
Mehdi's user avatar
  • 5,527
423 votes
10 answers
198k views

ASP.NET Identity - HttpContext has no extension method for GetOwinContext

I have downloaded, and successfully ran the ASP.NET Identity sample from here: https://github.com/rustd/AspnetIdentitySample I am now in the middle of implementing the ASP.NET Identity framework in ...
Darren Wainwright's user avatar
418 votes
26 answers
1.3m views

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated

I have many users on my web site (20000-60000 per day), which is a download site for mobile files. I have remote access to my server (windows server 2008-R2). I've received "Server is ...
SilverLight's user avatar
  • 20.2k
405 votes
20 answers
155k views

Visual Studio 2017 error: Unable to start program, An operation is not legal in the current state

After fresh installation of Visual Studio 2017 I tried to run .NET Core Web project and when trying to run it on Chrome I am getting this error: Unable to start program, An operation is not legal ...
Radenko Zec's user avatar
  • 7,669
403 votes
10 answers
510k views

How to get current page URL in MVC 3

I am using the Facebook comments plugin on a blog I am building. It has some FBXML tags that are interpreted by the facebook javascript that is referenced on the page. This all works fine, but I have ...
CatDadCode's user avatar
  • 58.8k
402 votes
11 answers
497k views

Response Content type as CSV

I need to send a CSV file in HTTP response. How can I set the output response as CSV format? This is not working: Response.ContentType = "application/CSV";
balaweblog's user avatar
  • 15.3k
400 votes
27 answers
256k views

Can I automatically increment the file build version when using Visual Studio?

I was just wondering how I could automatically increment the build (and version?) of my files using Visual Studio (2005). If I look up the properties of say C:\Windows\notepad.exe, the Version tab ...
Ian G's user avatar
  • 30k
398 votes
22 answers
451k views

"The Controls collection cannot be modified because the control contains code blocks"

I am trying to create a simple user control that is a slider. When I add a AjaxToolkit SliderExtender to the user control I get this (*&$#()@# error: Server Error in '/' Application. The ...
Daniel P's user avatar
  • 4,247

1
2 3 4 5
7495