Micro blog about Answer to the Ultimate Question of Life, the Universe, and Everything.
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home
  3. ASP.NET

Debug ASP.NET on IIS

Details
Written by: Stanko Milosev
Category: ASP.NET
Published: 30 December 2019
Last Updated: 06 April 2022
Hits: 2496
Here I already explained how to debug IIS express and here I explained how to add web site to IIS.

Now I am will give little bit more detailed explanation how to debug ASP.NET on IIS.

First start Visual Studio as administrator:

Set breakpoints and attach to process w3wp.exe:

If you don't see w3wp.exe then either refresh browser, or open your application in browser, and click refresh in "Attach to process" window.

String as a null

Details
Written by: Stanko Milosev
Category: ASP.NET
Published: 31 October 2013
Last Updated: 06 April 2022
Hits: 5476

In this article I have a bug :) Because I had a model like:

public String ReportSuccessToAddress { get; set; }

then in controller I had:

xmlReportSuccessCcAddress.Descendants("Value").Single().Value = startReportModel[i].ReportSuccessCcAddress;

In case that ReportSuccessCcAddress is null this line will fail. To automatically change null to empty string, in your model add annotation like:

[DisplayFormat(ConvertEmptyStringToNull = false)]
public String ReportSuccessToAddress { get; set; }

E - mail regular expression

Details
Written by: Stanko Milosev
Category: ASP.NET
Published: 21 October 2013
Last Updated: 05 October 2020
Hits: 6240
  • regular expressions

In your model, if you want to have e - mail validation, if user entered valid e - mail, you can use following regular expression: 

[RegularExpression("^(([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+)*$",
            ErrorMessage = "You must enter a valid email address for send Error Mail address. Multiple mail addresses must be separated with semicolons (no spaces)!")]

One example of the model is:

public class DistributionListsEditModel
{
	[DataType(DataType.Text)]
	public String Name { get; set; }

	[DataType(DataType.EmailAddress)]
	[RegularExpression("^(([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+([;|.](([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+)*$",
		ErrorMessage = "You must enter a valid email address for send Success Mail address. Multiple mail addresses must be separated with semicolons (no spaces)!")]
	public String ReportSuccessToAddress { get; set; }

	[DataType(DataType.EmailAddress)]
	[RegularExpression("^(([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+)*$",
		ErrorMessage = "You must enter a valid email address for send Error Mail address. Multiple mail addresses must be separated with semicolons (no spaces)!")]
	public String ReportErrorToAddress { get; set; }

	[DataType(DataType.EmailAddress)]
	[RegularExpression("^(([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+)*$",
		ErrorMessage = "You must enter a valid email address for send Success CC Mail address. Multiple mail addresses must be separated with semicolons (no spaces)!")]
	public String ReportSuccessCcAddress { get; set; }

	[DataType(DataType.EmailAddress)]
	[RegularExpression("^(([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+)*$",
		ErrorMessage = "You must enter a valid email address for send Error CC Mail address. Multiple mail addresses must be separated with semicolons (no spaces)!")]
	public String ReportErrorCcAddress { get; set; }
}

Composite primary key

Details
Written by: Stanko Milosev
Category: ASP.NET
Published: 21 May 2013
Last Updated: 21 May 2013
Hits: 11854

Definition:

Primary key is such an attribute which uniquely identify the record. Some times we needs more then one keys to find the specific record such scenario in which more than one keys are used to find the specific data is called the composite primary key.

From here.

Error:

Unable to determine composite primary key ordering for type 'MvcApplication7.Models.MyMaster'. Use the ColumnAttribute or the HasKey method to specify an order for composite primary keys.

Solution:

 

public class MyMaster
{
	[Key]
	[Column(Order = 0)]
	public int myField1 { get; set; }
	[Key]
	[Column(Order = 1)]
	public int myField2 { get; set; }
	public string Username { get; set; }
}
  1. Debug IIS express
  2. Debug JavaScript in Visual Studio 2010
  3. Playing with XML
  4. Routing

Subcategories

MVC 4

MVC 3

WebApi

Core

Page 1 of 12

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10