how can i solve this?
when i run my system through my local machine, it does not need any Log On to Database authentication, i can see my reports directly. but when i transferred my system into the server so the others can access it remotly, it requires a logon database and even the information is correct.
here my .cs code
public partial class PrintPreview : System.Web.UI.Page
{
ReportDocument crPrint = new ReportDocument();
protected void Page_Init(object sender, EventArgs e)
{
if (Session["ID"] == null)
{
Response.Redirect("../Account/LogIn.aspx");
}
else
{
string i = Session["tID"].ToString();
//CrystalReportViewer1.Visible = true;
string reportPath = Server.MapPath("../CrystalReport2.rpt");
crPrint.Load(reportPath);
crPrint.SetDatabaseLogon("sa", "Pr0cess", "172.20.3.24", "PO");
crPrint.SetParameterValue("MOSEFNo", i);
CrystalReportViewer1.ReportSource = crPrint;
}
}
}
the page always need the database log on when i transfer it to the database, how come?
and when i transfer the folder to the IIS, the "asp_client" folder is always empty, how do i fix this? thanks!
The problem is that when you reload the page the Session["ID"] will be reset to NULL. Try to check your Session State to state server mode.
Related
There is nothing wrong in the syntax of my code but whenever I try to run it keeps saying "The process cannot access the file because it is being used by another process". The only way I am running my application is my ending my application from the task manager. Please help me by explaining why this is happening and how to fix it.
private void btnLogin_Click(object sender, EventArgs e)
{
if (File.Exists("users.txt"))
{
string[] users = File.ReadAllLines("users.txt");
bool userFound = false;
foreach (string user in users)
{
string[] splitDetails = user.Split('~');
string username = splitDetails[1];
string password = splitDetails[2];
if ((txtBoxUsername.Text == username) && (txtBoxPassword.Text == password))
{
userFound = true;
break;
}
}
if (userFound)
{
Hide();
HomeForm home = new HomeForm();
home.Show();
}
else
{
MessageBox.Show("User details are incorrect",
"Incorrect details entered");
}
}
else
{
MessageBox.Show("No users have been registered", "No users");
}
}
private void btnRegister_Click(object sender, EventArgs e)
{
Hide();
RegisterForm registerForm = new RegisterForm();
registerForm.Show();
}
This application is for my a level software systems development coursework and I am coding it in c#. I have only been learning c# for the past 5 months so I am still a beginner. I have already tried to find the answer to my problem in stack overflow and other websites.
I am expecting my application to launch when I press run, but instead I get a dialog box saying:
Error Unable to copy file "obj\Debug\SSD AS2 coursework.exe" to "bin\Debug\SSD AS2 coursework.exe". The process cannot access the file 'bin\Debug\SSD AS2 coursework.exe' because it is being used by another process.
SSD AS2 coursework
Check if you are closing all windows of your application when finalizing the app.
You must use Application.Exit() in any events that are going to finalize your application.
You can read more on the Documentation
It seems like the file you are trying to open is being used by another process try to close your text editor or another program writing to that file.
it is still possible to overcome the issue by using FileShare.ReadWrite and use the file from multiple processes, example on the following code:
FileStream fileStream = new FileStream("c:\users.txt", FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
StreamReader fileReader = new StreamReader(fileStream);
while (!fileReader.EndOfStream)
{
string user = fileReader.ReadLine();
string[] splitDetails = user.Split('~');
// the rest of the user logic in here...
}
fileReader.Close();
fileStream.Close();
I have done a class which already works with the Dropbox API uploading files, downloading, deleting and so on. It has been working quite well since I was just using my own access token, but I need to register other users and a single but "big" problem appeared: retrieving the access token.
1.- Redirect URI? I'm starting to doubt why do I need this. I finally used this URI (https://www.dropbox.com/1/oauth2/redirect_receiver) because "The redirect URI you use doesn't really matter" Of course I included this one on my app config on Dropbox.
2.- I reach the user's account (I can see the user's count increased and I see the app has access to the user's account.
3.- I have a breakpoint on my code to inspect the variables in order to apply the DropboxOAuth2Helper.ParseTokenFragment but I have no success on there.
This is my code, but on the if before the try catch is where it gets stuck:
string AccessToken;
const string AppKey = "theOneAtmyAppConfigOnDropbox";
const string redirectUrl = "https://www.dropbox.com/1/oauth2/redirect_receiver";
string oauthUrl =
$#"https://www.dropbox.com/1/oauth2/authorize?response_type=token&redirect_uri={redirectUrl}&client_id={AppKey}";
private string oauth2State;
private bool Result;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Start(AppKey, webBrowser1);
webBrowser1.Navigating += Browser_Navigating;
}
private void Start(string appKey, WebBrowser w)
{
this.oauth2State = Guid.NewGuid().ToString("N");
Uri authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri(OauthResponseType.Token, appKey, redirectUrl, state: oauth2State);
w.Navigate(authorizeUri);
}
private void Browser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (!e.Url.ToString().StartsWith(redirectUrl, StringComparison.InvariantCultureIgnoreCase))
{
// we need to ignore all navigation that isn't to the redirect uri.
return;
}
try
{
OAuth2Response result = DropboxOAuth2Helper.ParseTokenFragment(e.Url);
if (result.State != this.oauth2State)
{
// The state in the response doesn't match the state in the request.
return;
}
this.AccessToken = result.AccessToken;
this.Result = true;
}
catch (ArgumentException)
{
// There was an error in the URI passed to ParseTokenFragment
}
finally
{
e.Cancel = true;
this.Close();
}
}
I've been fighting against this for hours and I'm starting to see the things a little cloudy at this point.
This is the tutorial I used, but I'm not moving forward. I would really appreciate any help!
EDIT: I finally made some steps forward. I changed the line which contains
Uri authorizeUri2 = DropboxOAuth2Helper.GetAuthorizeUri(appKey);
Now I'm showing the generated access token on the WebClient! Bad part comes when trying to get it (it gets inside the if) and it gets generated every time I ask the user for permission, so it gets overwrited.
EDIT 2: I noted the token I get generated on the browser is somehow malformed. I try to manually change it hardcored when I'm debugging and I get an exception when an AuthException when creating the DropboxClient object :( What the hell!
As Greg stated, the solution was using the event Browser_Navigated. Looks like the version of the embedded IE my Visual Studio (2015) uses didn't notice that if it's a redirect, it won't launch the event BrowserNavigating.
When I try to export my report from an aspx page using crystal report viewer I am prompted for a login everytime. (This only happens on export, not on load.) I'm using Visual Studio 2012 and SAP Crystal Reports 13.0.15.xxx.
Enter Values
The report you requested requires further information.
I have tried setting EnableDatabaseLogonPromt to False, but that generates this error:
"Method not found: 'CrystalDecisions.ReportAppServer.DataDefModel.ProperyBag...."
I think with my code is correct because the report loads into a new aspx page and receives data. But when I want to export my report or print it, I face that popup. I am using MSSQL SERVER 2012 AS DBMS so I don't need any username or password to log in. How can I correct this?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var x = Server.MapPath("~");
int CustomersId = Convert.ToInt32(Request.QueryString["CustomersID"]);
CustomersiDataSet Customersi = new CustomersiDataSet();
CustomersiDataSet.CustomersiTableDataTable CustomersiDT = new CustomersiDataSet.CustomersiTableDataTable();
var Customers = DA.Data.Services.DACustomersi.GetByCustomersId(CustomersId);
CustomersiDT.AddCustomersiTableRow(Customers.Name, Customers.LastName, Customers.IDNumber.ToString());
Customersi.Tables["CustomersiTable"].Merge(CustomersiDT);
ReportDocument ReportCustomers = new rpt_Customersi();
ReportCustomers.SetDataSource(Customersi);
CrystalReportViewer1.ReportSource = ReportCustomers;
//I ALSO TRIED WITH CACHING REPORT BUT THAT I AM FACING AGAIN ISSUE : MethodNotFound:"...."
// //Cache["Report"] = ReportCustomers;
// ReportCustomers .ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "MyCustomers");
}
}
I got a 2 ASP.NET solution. The first one is called HomePage and the other Main. I'm using IIS 7.5. At the root of IIS, I got 2 folders with the same name (HomePage and Main). Each solution is in their own folder.
I'm trying to transfer a session from HomePage to Main.
Main project (file ASPNETToASPNET.aspx)
private void Page_Load(object sender, System.EventArgs e)
{
string queryString = String.Empty;
string destPage = Request.Form["destpage"].ToString();
...
}
HomePage.aspx
private void Redirect_Click(object sender, CommandEventArgs e)
{
Response.Redirect("http://www.website.com/Main/Pages/ASPNETToASPNET.aspx?destpage=" + e.CommandArgument + "&SessionNoClient=" + Session["SessionNoClient"], false);
Response.Redirect("./Main/Pages/ASPNETToASPNET.aspx?destpage=" + e.CommandArgument + "&SessionNoClient=" + Session["SessionNoClient"], false);
}
When using the first redirect, I reach the appropriate file, but I got an error at line
string destPage = Request.Form["destpage"].ToString();
Object reference not set to an instance of an object.
When using the other redirect, I'm not able to find a way to reach the appropriate file.
As mentioned, both solutions are on same server and use the same domain.
Any solutions?
string destPage = Request.QueryString["destpage"];
This is not a transfer of session, you're just passing query parameters.
Request.Form collection contains POST values. For query string parameters (GET) use Request.QueryString or Request.Params, the last one searches your value in QueryString, Form, Cookies, and ServerVariables.
I have the following C# code in my code behind for a regular Web Application:
protected void Page_Load(object sender, EventArgs e)
{
if (!validTime())
{
btnEdit.Enabled = false;
btnSubmit.Enabled = false; btnSubmit2.Enabled = false;
lblSuccess.Text = "It is not currently the time to edit picks for this week.";
lblSuccess.ForeColor = System.Drawing.Color.Red;
if (picksMade())
{
displayCurrentPicks();
}
}
else
{
if (picksMade())
{
btnEdit.Enabled = true;
btnSubmit.Enabled = false;
btnSubmit2.Enabled = false;
displayCurrentPicks();
lblSuccess.Text = "Viewing your current picks";
lblSuccess.ForeColor = System.Drawing.Color.Green;
if (Session["Success"] != null && Session["Success"].ToString() != String.Empty)
{
lblSuccess.Text = Session["Success"].ToString();
lblSuccess.ForeColor = System.Drawing.Color.Green;
Session.Remove("Success");
}
}
else
{
btnEdit.Enabled = false;
btnSubmit.Enabled = true; btnSubmit2.Enabled = true;
displayCreatePicks();
lblSuccess.Text = "Create your picks for this week";
lblSuccess.ForeColor = System.Drawing.Color.Green;
}
}
}
The problem is, this code works great when I test it using ASP.NET Development Server. When I publish it to my live server it has some different behavior.
I have a web method that inserts data into my database with this signature:
[WebMethod]
public static void savePicks(List<string> Points, List<string> Teams, List<string> TieBreaker)
Again, on the test server it runs and works great. The problem is, when the method returns it should refresh the page, and it does, but on the live server my code in the page_load event is not run? or is run differently? It never calls the displayCurrentPicks() method? Or if it does, it does not run correctly? except it runs perfectly on the test server.
I have no way to check this stepping through the code because when I do it works great, on the test server. The live server is hosted on Godaddy.
And I have tried everything. I have tried doing page refreshes after the correct methods and in my javascript to force the page_load event to be run again. Nothing works. I have been at this for a few days now. And I am sure all my code is publishing. I have done all the usual 'stupid checks'. The data is making it to the database, the picksMade() function returns true when there is data there. The data is there by the time the page refreshes.
Why does the live server not run the code I publish to it? Why does it run something different? Or Behave differently? I understand it is a different server, but shouldn't it run the code the same?
What exactly does the function validTime() do? If you are checking for specific time constraints it may be that your development server is set to your local time zone and that is why it is working but on your live server the timezone may be different. Just a guess though.