http://asdf.com/something.do?param1=true?param2=false形式的网址是否有效?
我不认为第二个?允许在有效网址中,它应该是一个与号(&),但我无法在http 1.1 rfc中找到任何相关信息.有任何想法吗?
首先..请原谅我的英语不好,我希望能被理解.
我很高兴与LINQ合作,SQL对我来说是新的.
我正在尝试做下一件事:我在c#上有下一个方法:
public string niceMethod()
{
SqlConnection connection = new SqlConnection("Data Source=*******;Integrated Security=False;");
string commandtext = "SELECT bla FROM items WHERE main = 1";
SqlCommand command = new SqlCommand(commandtext, connection);
connection.Open();
string tDate = (string)command.ExecuteScalar();
connection.Close();
return tDate;
}
Run Code Online (Sandbox Code Playgroud)
我有页面例如: items.aspx?nID=144
我怎么能这样做SELECT命令将使用查询字符串,这将取值
来自"items"表的地址上显示的id(nID)?
该表的设计例如:id, title, bla, main.
我想使用XSLT解析一个youtube网址,并只从该网址获取视频ID.使用XSLT做到这一点的最佳方法是什么?
所以,如果网址是:http://www.youtube.com/watch?v = qadqO3TOvbQ&feature = channel&list = UL
我只想要qadqO3TOvbQ并将其放入嵌入代码中:
<iframe width="560" height="315" src="http://www.youtube.com/embed/qadqO3TOvbQ" frameborder="0" allowfullscreen=""></iframe>
Run Code Online (Sandbox Code Playgroud) 我的客户想要在某些页面上查询字符串(通过将%更改为A).
例如,我可以通过以下方式在所需页面上完全删除查询字符串:
RewriteCond %{QUERY_STRING} !=""
RewriteCond %{REQUEST_URI} ^/SpecialPage(.*)
RewriteRule ^(.*)$ /$1? [R=301,L] #remove query string
Run Code Online (Sandbox Code Playgroud)
这是我认为应该删除查询字符串上的%并替换为A,但它不是:
RewriteCond %{QUERY_STRING} ^(.*)\%(.*)$
RewriteCond %{REQUEST_URI} ^/SpecialPage(.*)
RewriteRule ^(.*)$ /$1?%1A%2 [L]
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?我只是无法发现它.感谢专家的眼睛!
我正在使用rails with devise进行注册.我还添加了一个邀请码,所以不是每个人都可以注册.
邀请代码通过查询字符串传输,如"/ users/sign_up?invite_code = wajdpapojapsd",并通过"f.hidden_field:invite_code,:value => params [:invite_code]添加到注册表单的隐藏字段中".
这非常有效.唯一的问题是,如果注册没有得到验证和拒绝,则设计重定向到"/ users"并丢失其中包含invite_code的查询字符串.
由于在尝试失败后电子邮件保留在注册表单中,我相信这也适用于邀请代码.作为最糟糕的解决方案重定向:在注册失败并丢失电子邮件后返回,但保留邀请代码,将比现在的工作方式更好.
编辑:到目前为止我已经为设计设置了一个注册控制器,但是不知道如何获得所需的行为.
有关如何保留查询字符串或仅提供邀请代码的任何帮助都很棒.
我想让我的通用路由确定是否像这样在Url中传递了查询字符串
http://localhost/query/DailyLogs/1?dateOfLog='1/13/2013'
Run Code Online (Sandbox Code Playgroud)
这是我当前的路线定义:
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "query/{controller}/{id}",
defaults: new { id = RouteParameter.Optional}
);
Run Code Online (Sandbox Code Playgroud)
我已经阅读了一些答案,说明将dateOfLog值添加为Route defintion的可选操作:
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "query/{controller}/{id}/{dateOfLog}",
defaults: new { id = RouteParameter.Optional,
dateOfLog = RouteParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用,也许我做错了什么,我不确定.
这就是我目前处理问题的方法,但我想使用路由引擎的ModelBinding功能:
var queryValue = Request.RequestUri.ParseQueryString();
string dateOfLog = queryValue["dateOfLog"];
Run Code Online (Sandbox Code Playgroud)
请告诉我如何创建一个正确使用ModelBinding的Route定义,并将我的自定义url映射到控制器的参数.
我创建了一个SVG文件,我打算用它作为CSS中的背景图像.我希望能够使用query-string参数更改SVG中的填充颜色,如下所示:
#rect { background-image: url( 'rect.svg' ); }
#rect.red { background-image: url( 'rect.svg?color=red' ); }
Run Code Online (Sandbox Code Playgroud)
据我所知,在SVG中使用脚本标签,我能够获取color参数并更新填充颜色.这是一个示例SVG:
<!DOCTYPE svg PUBLIC "-//W3C//DDTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" />
<script>
<![CDATA[
var params = { };
location.href.split( '?' )[1].split( '&' ).forEach(
function( i )
{
params[ i.split( '=' )[0] ] = i.split( '=' )[1];
}
);
if( params.color )
{
var rect = document.getElementsByTagName( "rect" )[0];
rect.setAttribute( "fill", params.color );
}
]]>
</script>
</svg>
Run Code Online (Sandbox Code Playgroud)
直接转到文件或使用对象标签似乎有效,但对于CSS背景图像或img标签,颜色参数将被忽略.
我不确定这里发生了什么,我希望有一个解释或替代解决方案,我正在努力完成(最好不要求助于服务器端处理).
这是一个显示不同渲染方法的jsFiddle: …
基本上我想要做的是通过让用户输入他们的帐户和他们的社会安全号码来验证用户.如果他们输入的组合不正确,我会在Authenticate后期操作中执行以下操作:
ModelState.AddModelError("Authenticated", authenticationError);
return View();
Run Code Online (Sandbox Code Playgroud)
这会显示错误,但后来我丢失了查询字符串中的内容.保留查询字符串的替代方法是:
ModelState.AddModelError("Authenticated", authenticationError);
return Redirect(Request.Url + "?returnUrl=" + returnUrl);
Run Code Online (Sandbox Code Playgroud)
这将保留查询字符串,但不会显示错误.我认为这是因为ModelState已经改变了.
我需要这个,returnUrl因为Authenticate只要用户点击查看特定事件,就会强制他们访问该页面.我想设置它,以便他们在验证自己后仍然可以参加此活动.
有没有办法可以同时保存查询字符串并显示模型错误?
如果我想让Node.js查询解析器解析一个数组,则可以发送以下代码:
'?or=foo&or=bar' // gets me { or: ['foo', 'bar'] }
Run Code Online (Sandbox Code Playgroud)
如果我想要一个对象,我可以这样做:
'?or[foo]=bar' // gets me { or: {foo: 'bar'}}
Run Code Online (Sandbox Code Playgroud)
但是,如何获取对象数组?我想要这个输出:
{ or: [{foo: 'bar'}, {bar: 'baz'}]}
Run Code Online (Sandbox Code Playgroud) 我知道Express会检查查询字符串(例如?a = 1&b = 2)并在默认情况下解析它.而req.query是包含键/值对的对象.有没有办法禁用此行为并完全忽略qs?
我需要这个,因为我解析查询字符串客户端,因为我收到大量的请求和qs很长我不想在每次解析查询字符串时浪费服务器资源(这意味着Express需要解码字符串中的URI组件,拆分字符串,为每个键值对执行for循环,为每对键做另一个拆分,创建一个非常昂贵的新对象等.这可能吗?
query-string ×10
c# ×2
javascript ×2
node.js ×2
url ×2
.htaccess ×1
asp.net ×1
asp.net-mvc ×1
c1-cms ×1
devise ×1
express ×1
http ×1
mod-rewrite ×1
parameters ×1
parsing ×1
ruby ×1
sql ×1
svg ×1
uri ×1
xslt ×1