Default page not rendering with Site.Master content - asp.net

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.

Related

Inherited an ASP.NET app & have some simple questions

I'm a PHP/Rails developer and have inherited an ASP.NET application (and its maintenance). So I have a few simple questions.
1.) What's the makeup of a typical rendered(compiled?) HTML page in ASP.NET. That is, when a request is made what happens from the initial request to the time the HTML is displayed in the browser? I'm assuming some templates are combined and finally rendered but I'd like a more in-depth answer.
2.) I've been asked to remove a link from a Login form which is an aspx page. Looking at the aspx page itself it has an inherit statement, a link to the codebehind file, and links some other resources. Where do I actually remove the link from the Login page/template at? I've so far been unable to find exactly where the link is written so that I can remove it or comment it out.
Thank you!
That is, when a request is made what happens from the initial request
to the time the HTML is displayed in the browser?
I'd start learning about the ASP.Net Page Life Cycle.
I've so far been unable to find exactly where the link is written so
that I can remove it or comment it out.
I wouldn't do anything until you have at least a decent grasp of how ASP.Net works. It would be good to run through a few tutorials. ASP.Net has a nice Get Started section.
What's the makeup of a typical rendered(compiled?)
To give you a very simple instructions (trying) to help you fast understand it:
There is a page with the aspx tags, the asp.net is running the code behind and fill this tags with data.
After the filling with data on code behind, the asp.net is "running" the full page and if you have <% %> inside the aspx page, addition code runs that exist inside that.
This is a simple example:
public partial class Dokimes_StackOverFlow_Diafora : System.Web.UI.Page
{
public string cRenderMeAlso = "test";
protected void Page_Load(object sender, EventArgs e)
{
txtText.Text = "One Test";
}
}
<form id="form1" runat="server">
This will fill when the page is prepared
<asp:Literal runat="server" ID="txtText"></asp:Literal>
<br />
This will be render as the page reads out to send it to the browser
as php do
<%=cRenderMeAlso%>
</form>
Now in the place of the Literal control, you can have a full custom render control, that maybe a new complex part of a page with his elements and render.
Each page, master page, user control have a cycle of calls to help first pass all from Init() and prepare them, then pass all from Load(), and the other stage, giving the ability to initialize them in parallel - together.
Now, on PostBack the page have been keep some information's on ViewState that are posted together with the rest post data, and the Code behind use all that data to fill the controls. Also its fires on code behind any click event you have initialize on buttons and you can run some code there to do your work.
I've been asked to remove a link from a Login form
if you can not find that link is maybe on the standard login form that asp.net gives, the solution to that is to render the full template of the form, and remove it from there - but because there is the case to break the Login form, is better to not remove it and just hide it - because if you remove it and the code behind ask for it, it will throw an error - I mean for the standard asp.net forms login code that is part of the asp.net.
So if this is the case, render the login control as template (from design mode, do that on properties), see the link you search and ether make on code behind Link.Visible = false, ether remove it and delete on code behind all the reference on it.

How do I redirect from one DotNetNuke module to another?

I am new to dotnetnuke.
I developed three modules in desktopmodules folder. like
desktopmodules(folder)
|
-- EnterpriseSearch(folder)
EnterpriseSearch.ascx
|
-- document search(folder)
docsearch.ascx
|
--result(folder)
result.ascx
result page is common to enterprice search and document search i want to redirect to result page from EnterpriseSearch and docsearch with parameter.
I tried with placing result module "type" as "view" and method of DotNetNuke.Common.Globals.NavigateURL
I tried with placing result module "type" as "edit"
editurl()
but i am not able to redirect it.
I dont want place theree pages in one folder (according to my requirements)
please give me the solutions to my question
Drop the EnterpriseSearch module onto a Content Page named EnterpriseSearch in your root DNN installation. Users will see "domain/EnterpriseSearch.aspx" in their address bar when visiting this page.
Drop the DocumentSearch module onto a Content Page named DocSearch in your root DNN installation. Users will see "domain/DocSearch.aspx" in their address bar when visiting this page.
Drop the Results module onto a Content Page named SearchResults in your root DNN installation. Users will see "domain/SearchResults.aspx" in their address bar when visiting this page.
In the codebehind of each search module, input the following code after a user clicks search (search button click handler)
Response.Redirect("/Search-Results.aspx?search=" & httpUtility.UrlEncode(TXT_Search.Text))
In your search results module at SearchResults.aspx, in your codebehind page-load function, do this:
Dim MyString as String = httpUtility.URLDecode(Request.QueryString("search"))
' perform search ...
Because the controls are in different modules, you'll need to use Globals.NavigateURL to navigate to a specific page that the module is on. If the result.ascx was a control of the same module, you could use EditUrl and pass in the control key, but that only working within the same module definition.
In this case, you should probably use ModuleController.GetModulesByDefinition to get the Result modules on the portal, then navigate to the page that one of the modules is on.
In view control button click event write below code like
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "WebUserControl", "mid=" + ModuleId.ToString()));
}
Follow below url instruction and redirection from one page to another page works.
http://www.dnnsoftware.com/Content/Dnn.Platform/Documentation/Using%20the%20Control%20Panel/Host%20Console/Extensions/Module%20Definitions%20and%20Controls/Adding%20a%20Module%20Control.html

Page_Load Is not Hit in SubFolder Default.aspx after Redirect to that Page

I have a page that sites in a first level folder from my root called default.aspx.
I'm redirected to that page like as so:
I have an initial root Default.aspx that holds a login button
User clicks the login button and it redirects to Facebook Login
After logging in, Facebook redirects back to my first level Default.aspx (sits inside root\firstlevelfolder\Default.aspx)
The page_load is not being hit. This is a .NET 2.0 solution in VS 2008. The AutoEventWireup is set to true in the page directive.
Not sure why and have not seen this error before. Does it have something to do with redirecting to a non root-level .aspx page? This is probably something fundamental but I"m not sure what it is.
breakpoint in the first line of code
in my page_load
You're using a breakpoint. Double-check that Visual Studio is in debug mode and your browser is pointing to localhost:1234 (where 1234 is some random port number assigned by the VS web server). Also, try doing a simple Response.Write("Hello World") in Page_Load(), and see if anything prints out on the top of the page.
You said to try the trace in the root.
No. Try it in the page that you think that Page_Load isn't firing on.
Also, on StackOverflow, it is much easier for others to follow the conversation, and it makes for a cleaner post if you can reply to questions using the "add comment" feature. The reason I'm posting another answer is just in case you're not aware of the feature and you miss the comment. See the SO Community FAQ item regarding comments.
Put a Trace="True" in your <%# Page %> line in the "first level" Default.aspx. The part that you would want to look at is the second section - "Trace Information". See if there is a "Begin Load" item in that list.
Also, is your page inheriting from the System.Web.UI.Page object, or do you have a custome base page?
public partial class _Default : System.Web.UI.Page //or do you have a different object here?
{
...
}
Does Page_Load get hit if AutoEventWireup is false?
Does the page that you are redirecting to work if you hit it directly from your browser without an intermediate page that redirects you there? I don't think the cause of your problem has to do with the fact that the page is in a subdirectory.
If the trace is showing that Begin Load is firing, then what methodology are you using to determine that Page Load doesn't work?

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)

Error appeared when I changed default page in visual studio

First, I did not like the index.cshtml page is that it contains the signature of Web API ASP.net, the API link, ...so on. And it also it contains the footer as '2015 # My Asp.net Application'.
So, is there a way that I can get rid of the header and signature? I found the solution as that could be at the master page, but I couldn't find the master page with extension (.master) in my application.
Please help me in getting rid of the header and signature of Asp.net Web API.
Second, I set another page as 'Set page as Start page' or as default page. Then when I changed my mind and came back and made the index.cshtml page as default page as it was, I got Server Error (page not found).
Please help me in either one way where I can create a new html page to add my code in it, and I can make it as start page without problems.
Or at least, let me fix the error that occurred in the index.cshtml page, where I can come back to it and use it again.
Thank you
In MVC razor the master page is referred to as the _Layout.cshtml page it can be found inside Views->Shared.
To set the default page you would have to set the default action and controller in the routing table
Footer
Ctrl+Shift+F Search Entire Solution for: "My Asp.net Application". This displays _Layout.cshtml as a search result.
Default Page
Go To Project > Properties > Web.
Remove Start Action Specific Page (make it blank).

Resources