小编Raj*_*ran的帖子

如何根据我的输入强制ASP.NET Web API返回JSON或XML数据?

我尝试根据输入获取输出XML或JSON数据.我使用了以下的WEB API代码,但无法准确输出.

public string Get(int id)
{
    if (GlobalConfiguration.Configuration.Formatters.XmlFormatter == null)
    {
        GlobalConfiguration.Configuration.Formatters.Add(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
    }
    if (GlobalConfiguration.Configuration.Formatters.JsonFormatter == null)
    {
        GlobalConfiguration.Configuration.Formatters.Add(GlobalConfiguration.Configuration.Formatters.JsonFormatter);
    }
    if (id == 1)
    {
        GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.JsonFormatter);                
        GlobalConfiguration.Configuration.Formatters.XmlFormatter.UseXmlSerializer = true;                
    }
    else
    {
        GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
        GlobalConfiguration.Configuration.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
    }
    return "value";
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api

40
推荐指数
6
解决办法
5万
查看次数

为什么PHP session_destroy()不起作用?

我尝试使用该session_destroy()方法销毁所有sesion变量,但在使用该方法后,不会销毁这些值.

为什么session_destroy()不工作?

有没有其他方法来破坏PHP中的会话?

if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) 
{   
    session_destroy();   
    session_unset();     
}
Run Code Online (Sandbox Code Playgroud)

php session

35
推荐指数
4
解决办法
12万
查看次数

自动添加新的最后一个数字mysql

我在我的表的一列中有这个id号,

0907003
0907004 
0907005

1008005 
1008006
1008007

1009001 
1009002
1009003 
Run Code Online (Sandbox Code Playgroud)

当我添加新值时1009,它将添加最后三个数字,004因为最后一个数字以1009(10-09)开头003.

或者如果我添加新值1008,它将添加最后三个数字,008
因为最后一个数字以1008(10-08)开头007.

或者如果我添加新值0907,它将添加最后三个数字,006
因为最后一个数字以0907(09-07)开头007.

这该怎么做?

提前谢谢了!

$front_id = $this->input->post('gameid'); //09
$middle_id = $this->input->post('netid'); //07

//$last_id will be generate automatically by sql 

$forID = $front_id.$middle_id; 

$sql = "INSERT INTO table ('colum') VALUES (".$forID.")"
Run Code Online (Sandbox Code Playgroud)

php mysql

6
推荐指数
1
解决办法
291
查看次数

为什么代码在重定向后执行

为什么使用header()重定向后执行goto

  $flag=1;
  if($flag==1)
      header("Location:page1.php");
  header("Location:page2.php");
Run Code Online (Sandbox Code Playgroud)

当使用此代码页重定向到page2.php时,为什么会发生这种情况

php

4
推荐指数
1
解决办法
2270
查看次数

当我点击浏览器中的按钮或链接时,如何播放声音,

如何播放声音文件,当我点击我的网页中的链接或按钮时,我还需要放置多个链接或按钮,每个链接或按钮都有不同的声音文件.

实际上我使用BGSOUND标签这样做只在IE中工作,

html php

3
推荐指数
1
解决办法
1万
查看次数

如何在PHP中的文件中间插入一些文本

如何在php中插入文件中间的一些文本,是一种可用于在文件内容中间插入文本的方法.

不完全是文件的中间.,搜索关键字,然后我们需要在内容之前或之后插入,

如果搜索关键字在文件中找到多个时间,则会发生wat

php file

2
推荐指数
3
解决办法
6584
查看次数

受保护的类在c#中的行为方式

我可以理解protected modifier如何对类成员(方法和变量)起作用,但是有人请告诉我Protected类的行为方式.

例如:-

namespace AssemblyA  
{  
  Protected class ProClass  
  {
     int a=10,b=10;
     public int get()
     {
        return a+b;
     }
  }  
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释受保护类的行为​​方式.

c#

1
推荐指数
1
解决办法
73
查看次数

标签 统计

php ×5

c# ×2

asp.net-web-api ×1

file ×1

html ×1

mysql ×1

session ×1