WebMatrix :: Acces The Subdomain From The Razor Syntax?
Jul 27, 2010How can I acces the subdomain from the razor syntax.forum.mysite.com ==> forumwww.mysite.com ==> www
View 8 RepliesHow can I acces the subdomain from the razor syntax.forum.mysite.com ==> forumwww.mysite.com ==> www
View 8 Repliesi would like to write Rss feed page using the razer syntax in webmatrix and i am facing probem in xml formatting
View 3 RepliesIn Windows Forms I can create a class file called 'Authentication.cs' with the following code:
public class Authentication
{
public string Name;
internal bool Authenticate()
{
bool i = false;
if (Name == "Jason")
{
i = true;
}
return i;
}
}
In WebMatrix, I can insert a new Class file, called 'Authentication.cs', and insert the above code. And in my default.cshtml file, I do this:.........................
While it has gnerally been advocated to separate code from mark up and all that, with the razor syntax and webmatrix all that is not valid anymore, I think. WebMatrix encourages code and mark up in the same page! So what is the best practice as far as code and mark up is concerned.
View 6 Repliesanybody tell me how to create WebService like asmx on razor syntax.
View 6 RepliesIt's great that Razor HTML encodes by default. However, many times I have HTML in a database and want to display it literally on a page. In WebForms 4, we can use <%= %> and <%: %> to choose between encoding options. Raven's syntax is currently @(new HtmlString(Model.Greeting)).
add a shorter syntax to Razor. Something like @=Model.Greeting or @@Model.Greeting, or something else.
I am trying to achive the following using Razor syntax, notice the lines in bold. I want to insert a '<tr>' tag based on a precondition.
[Code]....
However when I run this I get the following error Encountered end tag "tr" with no matching start tag. Are your start/end tags properly balanced?
My hosting company states they support .net and razor. However after uploading my website made with webmatrix and razor *.cshtml pages. When i visit my website all i get is 404.17 error messages. As an testcase i decided to add an standard .aspx page. Visiting that page gives the same 404.17 error message :-(
.
According to my webhoster my web.config is wrong. However that one is generated by webmatrix. Besides my *.cshtml *.aspx a lot of files and directories are added to the bin folder. What can i check and what should my hosting provider check. When using the check compatibility the asp.net version is shown as unknown? My hosting provider claims my site is running asp.net 4.0 in integrated mode and that should be enough.
For reporting we used report RDLCs and displayed using an ASPX form. We implemented using the route as shown below. This resulted in forcing us to use the page route below and also to use the hyperlink instead of the normal Action Link. The question is how do we convert the asp:hyperlink ASPX syntax to Razor syntax.
//Custom route for reports routes.MapPageRoute( "ReportRoute", // Route name "Reports/{reportname}", // URL "~/Reports/{reportname}.aspx" // File );
<li><asp:HyperLink ID="hypReport" runat="server" NavigateUrl="<%$RouteUrl:routename=ReportRoute,reportname=StaffRpt%>">Staff Report</asp:HyperLink></li>
I'm just starting out with WebMatrix and would like to know how to style a @Html.TextBox("email") and @Html.Password("password") control? I've tried (in my CSS file):
.email{
/* styles here */
}
.password{
/* styles here */
}
But that has no effect at all. How can we style these types of controls?
I have a problem with razor in a checkbox. It does not get a checked value. Here is the code:
[Code]....
How would I retrieve IP address with Razor? I have tried @Request.UserHostAddress and it returned ::1 to me instead of an IP adress. I am running this of course under IIS8 that came with webmatrix.
View 3 RepliesI am developing a project that has a DateTime field.
In it I'm using jQuery for the user to select the date format 'dd/MM/yyyy' taking into account that the date is not a required field.
How do you do to save DateTime fields not required in WebMatrix and Razor?
I was trying to do something like this:
I put only the code which I think is important to complete the code can be found here
@{
//Get data
string TaskForecastCompletion= Request["txtForecastCompletion"];
string TaskCompletedIn= Request["txtCompletedIn"];
DateTime dtForecastCompletion = default(DateTime);
[Code]....
I'm learning razor syntax, using the startersite in WebMatrix and trying to display some data from a table. I want to select only the data from the logged in user, so in effect want to say
...WHERE UserId =@WebSecurity.CurrentUserId";but that doesn't work.
Using the @0 method doesn't work for me either - I get an 'A parameter is missing. [ Parameter ordinal = 1 ]' error.
Do I have to set a variable then use the @0 / @1 / @whichever way? If so - what's wrong with this code?
@{
//Is the user logged in?
WebSecurity.RequireAuthenticatedUser(); [code]...
now if i want to iterate through the object it doesnt seems to work :
var myobject = new{param1 = "value1" , param2 = "value2" }
foreach(var i in myobject){
@i.Value
@i.Key
}
doesnt work.
Here is what I would like to express by Razor:
<b>@parameterMapping.Title</b> (Category: @parameterMapping.Category.Title, Regexp: @parameterMapping.Regexp)
But to make it parseable I have to write it this way:
<b>@parameterMapping.Title</b> <text>(Category: </text> @parameterMapping.Category.Title <text>, Regexp:</text> @parameterMapping.Regexp <text>)</text>
Are there better ways to solve this problem?
How does one create a .cshtml page in an ASP.NET web application? The option to choose Razor is obvious when using MVC - it appears when adding a view. But I can't seem to figure out how to accomplish this in a plain ASP.NET Web Application. Is it even possible?
View 1 RepliesWhen you do introduce intellisense and colorization to the razor editor, what about allowing the developer to choose the schema that it verifies against? If it could by default use a flavour of HTML, but optionally allow the dev to reference an arbitary XSD file (as supportted by the XML text editor). It could result in a very flexible experience that supports using ASP.Net MVC as a web service returning XML.
I can not get the _PageStart.cshtml to work for my layout senario. I would prefer to use _PageStart to define a layout for all files in each folder. Each folder represents a different app feature that will contain different layouts.
Until I find a work about I had to copy and past the Layout ="~/folder/_PageStart.cshtml into each page of the folder to get the different layouts to work.
_PageStart isn't being recognized at all as the folders page start. Is there a web config setting missing? The docs aren't fully extensive yet for all Razor related info and I couldn't find anyone discussing this problem via search results.
In order to keep close to code once and separation I need to use the _PageStart.cshtml method rather than code a line in each page in the folder.
On win7 using both webmatrix and vs2010 web engines. Neither recognizes _PageStart.cshtml but hard coding into each file works.
Following this tutorial: [URL]
Under "Sending a File Using Email" section what exactly is the code trying to do.
1: The SendFile.cshtml does not have any option to select file.
2: ProcessFile.cshtml is running fine. I am getting the email but no attachement.
I tried changing fileAttachment input to type="file" but not file is being sent to my email. I just get the message send in body.
Question: How exactly this file attachment works using Email Helper in WebPages.
Is it possible to somehow output some content based upon some conditional check in Razor? If not, I hope this possibility will be added in the future. What I want to do is the following:
[Code]....
was tagbuilder dropped in favour of Razor syntax?
If not, where did it go? It used to live in System.Web.Mvc -- not anymore.
I download and installed the latest version of MVC3 from this website [URL]. The MVC3 framework works but not the syntax highlighter for Razor or intellisense. Anyone knows how to make this work? Just for your information, I could not install the vs10-kb2483190-x86.exe.
View 6 RepliesCheck out the following: <a href="/test?x=@if (Model.IsTest) { @(1) } else { @(4) }"></a> Is there a better way to write this instead of the @(1) and @(4)?
View 1 RepliesI'm upgrading a regular asp.net project to asp.net mvc 3 (RC2) with Razor syntax. I got stuck now trying to figure out some way to create nested master pages. My main "layout" page contains the default header & footer. I used
[Code]....
When I now try to make a view page use the AuthLayout as a "layout" page:
[Code]...
Then I receive this error: The "RenderBody" method has not been called for layout page "~/Views/Shared/_AuthLayout.cshtml".