Skip to content

Commit 0660900

Browse files
committed
Check if id parameter can convert from string.
Resolve #20844
1 parent cffb178 commit 0660900

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.ComponentModel;
23
using System.Linq;
34
using System.Reflection;
45
using Microsoft.AspNetCore.Mvc.ApplicationModels;
@@ -35,7 +36,8 @@ public virtual string Build(
3536
var idParameterModel = action.Parameters.FirstOrDefault(p => p.ParameterName == "id");
3637
if (idParameterModel != null)
3738
{
38-
if (TypeHelper.IsPrimitiveExtended(idParameterModel.ParameterType, includeEnums: true))
39+
if (TypeHelper.IsPrimitiveExtended(idParameterModel.ParameterType, includeEnums: true)
40+
|| TypeDescriptor.GetConverter(idParameterModel.ParameterType).CanConvertFrom(typeof(string)))
3941
{
4042
url += "/{id}";
4143
}
@@ -156,4 +158,4 @@ protected virtual string NormalizeSecondaryIdNameCase(ParameterModel secondaryId
156158
{
157159
return secondaryId.ParameterName;
158160
}
159-
}
161+
}

0 commit comments

Comments
 (0)