Dynamic Gallery is not working online but working on localhost - asp.net

i have dynamic web Gallery in light box which is working fine in localhost but when i publish a site and then upload on server, gallery is not showing the images online...
i had to take the page property "AutoEventwireup=true" because i need to call page events automatically... and i think it`s creating problem online but working fine in localhost..
is my assumption correct about AutoEventWireup="true"???
Note: i have already granted a permission to image folder in server so it`s not a cause of configuring the IIS...
Any Help or suggestion plz?
Updated:
Download the Demo of photo Gallery (no database required it will be handled by xml data)
You can upload from admin and display to client, there are two pages first is imageupload.aspx in Admin folder which will be uploaded and second is photogallery.aspx where images will be displayed and the third one which i have to mention is xml file in which xml nodes are created, xml file is inside a data folder
Download Link
https://drive.google.com/file/d/0B_f0_xt7mMiwTXc2T0dFS0MzWE0/edit?usp=sharing

No your assumption is not correct. AutoEventWireup="true" allows you to handle standard page events using their default names, for example: -
protected void Page_Load(object sender, EventArgs e)
{
// your code
}
If you set AutoEventWireup to false, you must explicitly override the named function: -
protected override void OnLoad(EventArgs e)
{
// your code
}
Can you post your code please - the page, and the image gallery ?

Related

Default page not rendering with Site.Master content

I have a hosting account with GoDaddy.com, IIS 7 server running .NET 4.0, and I am in the early stages of developing a web site for our church. The content is a free CSS based template I have moved into an ASP.NET Web App with Master pages. (If critique on content is necessary please keep in mind this is a very early stage of development...but I am open to any suggestions. :) )
For some reason, when I enter the full URL to the default page, the page renders properly. However, if I only enter the folder name without the page name, I only get the content form the page itself.
See for your self:
http://www.websmithsllc.com/lpacftp/Home.aspx
http://www.websmithsllc.com/lpacftp
I don't think this is an issue with my wire-up between the content page and the masterpage as it will properly render when I use the full URL. Therefore, I assume the issue is in one of three areas:
How I am publishing: One Click to an FTP directory
The project settings: Currently Home.aspx is the start page
An issue with the settings on my host.
I really hope the issue isn't #3 because my experience so far has been that their tech support is severely lacking in the area of Visual Studio / IIS development and publishing.
Now, some additional clues. I KNOW that the Site.Master file is being rendered, at least to some extent. The menu that is being displayed is created in the Site.Master.Page_Load event handler:
protected void Page_Load(object sender, EventArgs e)
{
//Load sidebar content
Page p = HttpContext.Current.CurrentHandler as Page;
menuContent.Text = Helpers.StaticHelperMethods.GenerateMenuContent(p.Title);
}
Static method:
public static string GenerateMenuContent(String pageTitle)
{
StringBuilder menu = new StringBuilder();
if (pageTitle == "Home")
{
menu.Append("Home\n");
}
else
{
menu.Append("Home\n");
}
More similar code...
In this case, p.Title should == "Home", but the code is responding as though is does not, and I don't know how (if I can) debug live to see what's going on. Finally, if you look closely at the second link, you'll notice some stock ASP.NET advertising text- that appears to be coming from the stock "Default.aspx" file in the BodyContent asp:Content object. However, looking at the properties/Web tab I can see that the startup action is Specific Page : Home.aspx.
So- hopefully I haven't added a ton of unnecessary info here, but at least enough for someone with more experience to help me figure out what I'm doing wrong here.
Thanks in advance for whatever help you can offer me on this.
You need a default page. Create it and then in the code behind in Page_Load write:
Response.Redirect("Home.aspx");
Or change your default page in IIS. Or change your home page to Default.aspx (and rename the class and the page directive).
Of the three, creating a Default.aspx page that redirects to Home.aspx is likely the easiest.
Yes, MatthewMartin is correct. Your hosting service's IIS is not configured to pick up "Home.aspx" as a default page. You will need to either get them to add it to the IIS configuration, or rename your home page to Default.aspx, or create a "dummy" Default.aspx that redirects to your Home.aspx.

Server.Transfer doesn't update all paths

Using Server.Transfer to show a page that informs the user that the web site is at maintenance mode.
At global.asax:
void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.IsLocal)
return;
if (ConfigurationManager.AppSettings["MaintenanceMode"] == "true")
{
if (Request.AcceptTypes != null && Request.AcceptTypes[0] == "text/html")
Server.Transfer("~/UserMessage.aspx?Maintenance");
}
}
Works well except when looking at the page source code I see that the CSS path has been updated but images' paths are not.
Any suggestions?
I would use app_offline.htm in the application root or at the very least Response.Redirect if I were you, Server.Transfer does not change the HTTP address, so you have to be careful redirecting all assets to the underlying page or make all addresses absolute
The server.transfer is actually stop the execution of a page and start execute a different page, the page that you give it.
The result is that the user see a different page under the same url.
This have nothing to do with image path. Also the images are not pass from asp.net except if you have set even images to pass from asp.net processing. Also on the code that you have give us you do not make any transfer if they are images, but you check for the text/html.
Now if you have move the execution to a different css, the image path is not change, only the page that the user see change.
Maybe you mean that you use the MapPath() and this is not change according to the new directory ?

Response.Redirect is redirecting to a page that doesn't exist

I'm doing a simple check for some user data that get's put into session on sign in. What happens, is I click through a few buttons to get to this page. This page a has a drop down that is set to autopostback=true.
When I change my selection in the drop, my request get's redirected to a page that doesn't exist. signin.aspx exists in the root folder of the site. The attempted redirect looks for signin in the folder that this particular page is in (example.com/folder1/signin.aspx) instead of example.com/signin.aspx.
Should I be using something other than Response.Redirect to accomplish this?
Side note about the application:
This is .net 4 using jquery 1.6.4 and jquerymobile 1.0. I'm thinking jquery mobile is the problem because I use this same pattern/practice on other applications without issue.
Location of page where this is happening.
example.com/folder1/page2.aspx
location of sign in page: example.com/signin.aspx
url that displays in the error. example.com/folder1/signin.aspx
protected override void OnInit(EventArgs e)
{
if (Session["UserData"] == null)
{
Response.Redirect("../SignIn.aspx");
}
}
You should always use asp.net style root-relative paths:
Response.Redirect("~/SignIn.aspx");
That makes the URL relative to your site's root (not the web root unless your site is the web root), but still allows the site to be moved around.
jquery wouldn't be affecting a server side response.redirect. Are you sure that the page exists as it's being set in your code? If signin.aspx is in the root of the website, could you not simply do this?
Response.Redirect("/SignIn.aspx");
Try This
protected override void OnInit(EventArgs e)
{
if (Session["UserData"] == null)
{
Response.Redirect("~/SignIn.aspx");
}
}

Is there any way to load a master page from outside the current application?

I'm prototyping an environment where multiple applications run on the same server, but they all share a master page.
Is it possible to load a master page from another application? In one of my applications, I have this code:
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
this.MasterPageFile = "~/../MasterPages/Root.master";
}
What this does is set the master page to a file sitting outside my current application. (Note the ".." after the tilde -- so I'm going to the root of my current app, then stepping up a directory to find a master page.)
ASP is displeased with this:
The virtual path '/MasterPages/Root.master' maps to another application, which is not allowed.
I understand that it might be stressed out about the fact that there's no backing class for it, but what if I have nothing in the code-behind, and I choose not to inherit my master page from anything -- so the entire thing is contained in the ".master" file?
Is there any way to do this?
You might consider mapping a virtual directory into your apps folder structure, then that directory can be mapped to multiple applications at the same time.
Just thinking of the cuff but what if you create a virtual directory under each application which maps to the same physical directory:
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
this.MasterPageFile = "~/MasterPages/Root.master";
}
So you might have a physical layout of:
c:\inetpub\wwwroot\MasterPages
c:\inetpub\wwwroot\App1
c:\inetpub\wwwroot\App2
You'd then have IIS set up like:
root\App1
root\App1\MasterPages
root\App2
root\App2\MasterPages
We made our master page very generic. Each master page would use a WebRequest to capture our common horseshoe html (or .aspx) page.
The hardest thing about this approach is we had to put markers in the horseshoe. These markers would indicate what the application could replace and where to place its content.

Passing value through querstring without showing the destination page in the URL with ASP.NET web form

I have a small web app being written in ASP.NET, VB.NET , .NET 3.5
I pass a value from default.aspx to demo.aspx using query string. When Go button is clicked the URL will be like this : localhost/demo.aspx?id=4
But I want URL to be sth like this when Go button is clicked : localhost/?id=4 and the id value is passed to demo.aspx so the expected result can be shown. How to get this done if possible without using the routing technique.
This will work only if the web server considers demo.aspx to be the default document. When you load a page without stating the page name (such as you localhost/?id=4 example), the web server will locate a file with a pre-defined name and use it as the default document. Often this file is called default.aspx (or .asp, .htm, .html, .php or something like that). So if you want to load any other page you will need to either state the name, or use URL rewriting techniques.
Modify your go button to link button and set herf = "?id=[id]"
Modify Page_Load event of Default.aspx by using the following code.
public Page_Load(object sender,EventArg e)
{
if(!string.IsNullOrEmpty(Request["id"]))
{
// Using Server.Transfer() function to call Demo.aspx page.
// Client still see "localhost/?id=[id]" at address bar.
Server.Transfer("Demo.aspx?id=" + Request["id"]);
}
}
Something like this?
protected void btnGo_Click (Object sender, EventArgs e)
{
Response.Redirect("localhost/?" + Request.QueryString);
}
Not sure when you want the url to change? Not sure what the routing technique is either. Sorry.
if you want it to work with postbacks, you still need to make sure the webserver is configured with a default document like default.aspx.
in 3.5 sp1 MS finally allows us to set the action attribute of the form.
so on page init you can explicitly set it now
Form1.Action = "/mydirectory/"
Caveat: Some versions of IIS do not allow posting to a directory. (XP IIS for example)

Resources