c# - 如何在 MVC 中将 URL 作为查询字符串参数传递

标签 c# asp.net-core asp.net-core-mvc

有谁知道如何将 URL 作为查询字符串参数传递,然后在 HttpGet 方法中获取 URl 作为参数?

最佳答案

非常感谢您的所有回答。最后我把它整理好了。请引用下面我的修复:

[Route("api/[controller]")]
public class UrlController : Controller
{
    [HttpGet("{*longUrl}")]
    public string ShortUrl(string longUrl)
    {
        var test = longUrl + Request.QueryString;

        return JsonConvert.SerializeObject(GetUrlToken(test));
    }

关于c# - 如何在 MVC 中将 URL 作为查询字符串参数传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30648222/

相关文章:

javascript - 如何从 html 获取对象 Id 返回 Controller MVC c#

azure - .Net Core 2.0 Web API - 由于析构函数问题导致服务器崩溃

asp.net - 混合自定义和默认模型绑定(bind)

angular - 从源访问 XMLHttpRequest 已被 CORS 策略 : No 'Access-Control-Allow-Origin' header is present on the requested resource 阻止

asp.net-core - 带有 anchor 标记助手的命名路由

c# - 使用 Entity Framework Code First Development,我可以让它在现有数据库中创建一个或多个表吗?

c# - 是否可以将不同的接口(interface)绑定(bind)到实现所有接口(interface)的类的同一个实例?

c# - 为什么这个 LINQ 表达式会破坏我的循环和转换逻辑?

c# - Swashbuckle SchemaFilter 用于 api 操作参数

security - 如何获取 Asp.Net Core 加密 key 的访问权限?